I am posting this question because I have a problem with my beginner programming project.
I am new in the use of gtk and I am blocked by a problem that I wish to expose to you.
For my program to work I need to clear my store list and rewrite it, but when I run my gtk_list_store_clear(store) function my compiler displays an error of this type.
enter image description here
void actualize_index_of_rep()
{
int i;
GtkTreeIter iter;
for(i=0;i<rep_size;i++)
myRep[i].index=i;
gtk_list_store_clear(store);
for(i=0;i<rep_size;i++)
{
gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,0,myRep[i].name,1,myRep[i].tel,2,myRep[i].index,-1);
}
return;
}
For people who want the entire code he is here
enter link description here
And the save file
enter link description here
Thank you in advance for your time :)
I pulled down a copy of your program, built it, and ran it. I encountered the same issue. To be brief, after adding in some "g_printf" statements to track the process, I discovered that you had two functions called when a row is selected and the deletion button is clicked.
remove_from_prog();
remove_from_list();
When I scanned through the first function, I saw that it was saving a copy of the list out to your "save.data" file, omitting the selection that was deleted. The function then rebuilds the list and view. So, when the second function is called ("remove_from_list"), it can no longer find the row selection which then throws the error you see. The bottom line is that it appears that you do not even need the "remove_from_list" function.
Hope that helps.
Regards.
Related
So I am working on this side project game kinda thing, and I want to put it inside of a border/box. I then want to print text constantly inside that border: adding text, removing it, changing it etc. I've looked far and wide, and cannot find anyway to print inside the box separately from the actual box.
My current implementation is to clear screen, and then reprint the entire box with new text using this:
printf("\e[1;1H\e[2J");
The issue with this is that I get this very obnoxious blinking effect, because every iteration of clearing my screen causes that portion of the screen to become black for a certain period of time.
So I am looking for a few solutions.
How to print a border separate from the print statement inside of it. I currently am implementing it like such:
printf("| | Hello There ||\n");
, and then repeating that all the way down to make a border.
How to completely overwrite the already outputted text so that this blinking effect can go away. So imagine \r removing a line, I want something like that, that removes the whole text and replaces it with a new set of text
How to change the location of where the user inputs into the console, so you can type into a box
Those are basically the only solutions I could think of, if you have any others I'd love to hear them
I also had a general question about c.
conio.h, graphics.h, windows.h and a few other headers don't work for my compilers. I use ubuntu, and they always come up with some error saying I can't use them. I appreciate someone explaining this to me.
Please let me know what you think, and if you need more info, I'll be sure to provide it
-Ryan
conio.h and windows.h are not standard Linux libraries, so they won't compile on Linux unless you install extra software. One solution would be to use a library designed for managing the screen like ncurses.
You can do that with loops and ASCII characters similar like that:
#include <stdio.h>
int main()
{
int i;
printf("\n\t\t═");
for(i=0;i<=20;i++)
{
printf("═");
}
for(i=0;i<=22;i++)
{
printf("\t\t║\n");
if(i==10)
{
printf("\t\t\tHello There \t\n");
}
printf("\t\t\t\t\t║\n");
}
printf("\t\t═");
for(i=0;i<=22;i++)
{
printf("═");
}
return 0;
}
I’m in love with IUP! However I cannot figure out how to get programmatic access (in C) to GUI elements in a dialog loaded by IupLoad() from a LED file.
One extremely laborious way would be to edit the LED file so as to manually give handle names to each single GUI element, then manually define corresponding variables for each element in C, then manually load handles into each variable by using IupGetHandle().
One comfortable way to do it would be to convert the LED file to a C header file using the built-in Layout Dialog tool. The resulting code makes each element available to the application in a simple array called Ihandle* containers[]. But this way deprives us of the benefits of LED files, such as the ability to edit GUI of a binary application by the user and keeping the C code small.
Is there no good way to do it?
Do I overrate the benefits of a third way, if it existed?
I cannot find any IupLoad() example in the directory with C examples.
My own example below explicitly defines one handle name for the top element (dialog) only. It features a very simple dialog where defining each element manually wouldn’t be a hard work at all. But this is only a test example for Stack Overflow and my question is relevant to complex dialogs.
C file:
#include <stdlib.h>
#include <iup.h>
int main(int argc, char **argv)
{
IupSetGlobal("UTF8MODE", "YES");
// IupSetGlobal("UTF8MODE_FILE", "YES");
IupOpen(&argc, &argv);
if(IupLoad("dropdown.led")) IupMessage("Error", "Failed to load LED.");
else {
Ihandle *dropdown = IupGetHandle("dropdown");
IupShow(dropdown);
IupMainLoop();
}
IupClose();
return EXIT_SUCCESS;
}
Corresponding dropdown.led file:
dropdown = DIALOG[TITLE=dropdown.led](
HBOX[CMARGIN=10x10,CGAP=10](
LIST[VALUE=3, 1=я, 2=ты, 3=оно, 4=мы, 5=вы, 6=они, DROPDOWN=YES](do_nothing),
LIST[VALUE=3, 1=ik, 2=je, 3=hij, 4=we, DROPDOWN=YES](do_nothing)
)
)
Which brings us to another question: how can I make Russian characters visible? But this issue is owed a separate thread which I will accordingly create.
All questions that pertain to this particular example:
How do I get access to GUI elements in a IUP dialog loaded from a LED file? (current)
How can I make Russian letters visible in a IUP dialog loaded from a LED file?
A gap in IUP dropdown lists
The way os to use IupGetHandle to get access to some element then use IupGetChild*, GetBrother, GetParent functions to get the element you want.
Another option is to use the NAME attribute. You set it on the element you want then use IupGetDialogChild to retrieve the element given the NAME value.
I just started with PETSC and I'm trying to plot a matrix using matView. My code is like:
MatCreateSeqAIJWithArrays(PETSC_COMM_WORLD, nodes, nodes, rows, cols, values, net); //I want to visualize "net"
//Visualization
if(display >= 1){
PetscPrintf(PETSC_COMM_WORLD, "CSR structure created.\n");
MatView(*net,PETSC_VIEWER_DRAW_WORLD);
}
When I use MatView this way:
MatView(*net,PETSC_VIEWER_STDOUT_WORLD);
I can see a list with the rows. But when I change it to
MatView(*net,PETSC_VIEWER_DRAW_WORLD);
nothing happens.
I can't see anything about net structure, not even the list.
I tried to run the examples but they don't work at all. Also, the PETSC documentation just makes things worse. Can someone help me? I don't want to see a list of rows, but the matrix (graphically).
More context from the comments:
X windows is functioning properly -- was able to confirm with gvim, xlogo, xeyes, etc.
Library has been rebuilt using --with-x option in configure. Still nothing appears.
Try using "-draw_pause -1" as an argument to your PETSc program, if you're not doing it yet.
-draw_pause - Sets time (in seconds) that the program pauses after PetscDrawPause() has been called (0 is default, -1 implies until user input).
I'm trying to save color of vertices using vcglib but failed. Even if I read a file in and save it out without doing anything, the color of the original file is lost.
Here is the code I wrote:
vcg::tri::io::ImporterPLY<MyMesh>::Open(*srcMesh,"bunny.ply");
vcg::tri::io::ExporterPLY<MyMesh>::Save(*srcMesh,"out.ply");
After doing this, out.ply has no color while the source ply bunny.ply does.
Could anybody give me some sample code to make this thing done?
Thank you!
I had the exact same problem a couple of weeks ago.
After spending some time with the debugger and browsing through lots of source code, I discovered that the the open and save methods need to share an int mask. This allows the Open method to convey which attributes have been read from the original mesh (Also, make sure you've added the Colour4b attribute to your mesh definition.
int mask=0;
vcg::tri::io::ImporterPLY<MyMesh>::Open(*srcMesh,"bunny.ply",mask);
vcg::tri::io::ExporterPLY<MyMesh>::Save(*srcMesh,"out.ply",mask);
I hope that helps.
I've added this line to hook_preprocess_page in template.php:
if (isset($vars['node']) && $vars['node']->type=='landing_page') {
$vars['theme_hook_suggestions'][] = 'page__'. $vars['node']->type;
}
This worked fine on my test server however now I have put it on staging and has caused:
A) Only the page template is output - it is not surrounded by html.tpl.php.
B) My preprocess_html function in template.php is not being called at all.
If I comment out the line then html.tpl.php is used again.
This thread is discussing similar but opposite problem.
I'm really stumped on this - any points would be really useful!
This was being caused by calling an undefined function in my page template.
This wasn't apparent until I started searching the error logs.
Hope this may save someone else some time...