Posted March 11, 2023
low rated
I'm going out of my mind, even farther than usual, because I've been trying to implement something that should be extremely simple using wxWidgets, and should probably take less than an hour, but for some reason, I just can't get it to work at all, and I have barely any time to work on it, so I end up spending a couple hours or so, once every week or two, and months have gone by, yet I've made very little progress, and many times I make none at all!
I've already been to Stack Overflow, and as always, their advice is virtually useless, on the rare occasions that they actually reply to me (and I can't even post a follow-up there unless it's a relatively short "comment", because the only other way that I can see to do it is by posting an "answer", but I have no answers at all - only questions), so I thought I'd post here, since people on this website tend to be far more helpful, despite it not even being a programming website.
They did tell me to try using a GUI tool to automatically make the thing, bu that doesn't work well at all, because three were recommended, but a couple of them are incompatible or I have no reasonable way of installing them, and the one that I managed to get to run is wxFormBuilder, but it doesn't seem to have the necessary tools or capabilities, or otherwise I just can't figure out how to get it to work (for example, I can make various controls, but they don't appear correctly in the hierarchy, and even when I move them around, they still don't become children of the proper parents, and when I make something like a notebook, I can't even make tabs for it, etc.).
So what I REALLY need is for someone to just fix my tiny amount of code for me. Links to tutorials are also welcome, because I understand the teaching a man to fish philosophy, but at this point, I'm afraid I may just be incapable of learning how to fish and I'm starving to death, so I'm begging you to just PLEASE give me a FISH!!!
All I'm trying to do is make a window (or frame, or whatever) with a menu bar along the top, then fill the whole thing with a notebook with various tabs which will be added as needed. Then within the notebook I want to split it into a left and right section (using a splitter window, I suppose, unless there's a better way), such that it shows different content on each tab, except that in all cases, the left section has a customizable tree control, and the right section contains yet another notebook control. Within this notebook control, the content, and even its format, should be completely customizable for different tabs (I'll provide the code for each circumstance, but I just need the notebook and its tabs to appear).
So far, I've written the code for the main notebook, splitting it into a left and right part, and putting a tree on the left part, but I haven't put the smaller/nested notebook on the right part yet. But I haven't even gotten all of this working yet, because depending on how I set it up, it sometimes shows the tree and other times it doesn't display, and it sometimes shows different things on different tabs, but other times it changes nothing when I click the tabs. Sometimes I get an error that says I've assigned the sizer to the wrong control with the wrong parent or something, but when I fix that so that the error disappears, the tree stops displaying correctly, if it even did in the first place, which is also iffy.
In any case, I just can't get it all to show up correctly and act properly without errors, no matter what I try, and it seems like I've tried every possible combination, but a working example would be EXTREMELY helpful! Unfortunately, it seems like the entire Internet has VERY little information on wxWidgets, and even less on wxFormBuilder, especially for the controls that I'm specifically using, so it's like I have no way of getting the information I need, because it simply doesn't exist! Does everyone have these problems when using this garbage tool, or is it just me?
Anyway, here's the code that I had initially written:
wxPanel* parent = new wxPanel(this, wxID_ANY);
wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL);
wxNotebook* notebook = new wxNotebook(parent, wxID_ANY, wxDefaultPosition, this->GetSize());
wxPanel* notebookWindow = new wxPanel(notebook, wxID_ANY);
parent->SetSizer(vbox);
Center();
Maximize(true);
notebook->SetSize(this->GetSize());
notebook->AddPage(notebookWindow, wxT("Tab one"), true, 0);
notebook->AddPage(notebookWindow, wxT("Tab two"), true, 0);
wxSplitterWindow* splitterWindow = new wxSplitterWindow(notebookWindow, wxID_ANY);
wxTreeCtrl* tree = new wxTreeCtrl(splitterWindow, wxID_ANY, wxPoint(0, 0), wxSize(200, 1000), wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT | wxTR_HIDE_ROOT | wxTR_EDIT_LABELS);
wxTreeItemId rootID = tree->AddRoot(wxT("Root"));
wxTreeItemId item1ID = tree->AppendItem(rootID, wxT("Item 1"));
wxTreeItemId item2ID = tree->AppendItem(rootID, wxT("Item 2"));
wxTreeItemId item3ID = tree->AppendItem(rootID, wxT("Item 3"));
wxTreeItemId item4ID = tree->AppendItem(item2ID, wxT("Item 4"));
vbox->Add(splitterWindow, 1, wxALL | wxEXPAND, 5);
I was told that I needed to make different windows for each tab, or else it wouldn't change the content when I switched between them, which makes sense, so I changed some things around, and got this:
parent = new wxPanel(this, wxID_ANY);
wxBoxSizer* vbox1 = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* vbox2 = new wxBoxSizer(wxVERTICAL);
wxNotebook* notebook = new wxNotebook(parent, wxID_ANY, wxDefaultPosition, this->GetSize());
wxPanel* firstWindow = new wxPanel(notebook, wxID_ANY);
wxPanel* secondWindow = new wxPanel(notebook, wxID_ANY);
firstWindow->SetSizer(vbox1);
secondWindow->SetSizer(vbox2);
Center();
Maximize(true);
notebook->SetSize(this->GetSize());
notebook->AddPage(firstWindow, wxT("Tab one"), true, 0);
notebook->AddPage(secondWindow, wxT("Tab two"), true, 0);
wxSplitterWindow* splitterWindow = new wxSplitterWindow(firstWindow, wxID_ANY);
wxTreeCtrl* tree = new wxTreeCtrl(splitterWindow, wxID_ANY, wxPoint(0, 0), wxSize(200, 1000), wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT | wxTR_HIDE_ROOT | wxTR_EDIT_LABELS);
wxTreeItemId rootID = tree->AddRoot(wxT("Root"));
wxTreeItemId item1ID = tree->AppendItem(rootID, wxT("Item 1"));
wxTreeItemId item2ID = tree->AppendItem(rootID, wxT("Item 2"));
wxTreeItemId item3ID = tree->AppendItem(rootID, wxT("Item 3"));
wxTreeItemId item4ID = tree->AppendItem(item2ID, wxT("Item 4"));
vbox1->Add(firstWindow, 1, wxALL | wxEXPAND, 5);
vbox2->Add(secondWindow, 1, wxALL | wxEXPAND, 5);
But that caused other problems with the tree not appearing correctly, and so on. Keep in mind that I'm just making a couple of test tabs now, and eventually I'll be making them programmatically, to add as many as needed whenever necessary at run time, but for now, this kind of simple example should work fine, just to get the interface working. But what have I done wrong? Could someone just fix this code to get it to work, also with the nested notebook placed to the right of the tree control, in the right window within the splitter window, PLEASE?! Thank you very much if you can fix this, because I'm desperate!
I've already been to Stack Overflow, and as always, their advice is virtually useless, on the rare occasions that they actually reply to me (and I can't even post a follow-up there unless it's a relatively short "comment", because the only other way that I can see to do it is by posting an "answer", but I have no answers at all - only questions), so I thought I'd post here, since people on this website tend to be far more helpful, despite it not even being a programming website.
They did tell me to try using a GUI tool to automatically make the thing, bu that doesn't work well at all, because three were recommended, but a couple of them are incompatible or I have no reasonable way of installing them, and the one that I managed to get to run is wxFormBuilder, but it doesn't seem to have the necessary tools or capabilities, or otherwise I just can't figure out how to get it to work (for example, I can make various controls, but they don't appear correctly in the hierarchy, and even when I move them around, they still don't become children of the proper parents, and when I make something like a notebook, I can't even make tabs for it, etc.).
So what I REALLY need is for someone to just fix my tiny amount of code for me. Links to tutorials are also welcome, because I understand the teaching a man to fish philosophy, but at this point, I'm afraid I may just be incapable of learning how to fish and I'm starving to death, so I'm begging you to just PLEASE give me a FISH!!!
All I'm trying to do is make a window (or frame, or whatever) with a menu bar along the top, then fill the whole thing with a notebook with various tabs which will be added as needed. Then within the notebook I want to split it into a left and right section (using a splitter window, I suppose, unless there's a better way), such that it shows different content on each tab, except that in all cases, the left section has a customizable tree control, and the right section contains yet another notebook control. Within this notebook control, the content, and even its format, should be completely customizable for different tabs (I'll provide the code for each circumstance, but I just need the notebook and its tabs to appear).
So far, I've written the code for the main notebook, splitting it into a left and right part, and putting a tree on the left part, but I haven't put the smaller/nested notebook on the right part yet. But I haven't even gotten all of this working yet, because depending on how I set it up, it sometimes shows the tree and other times it doesn't display, and it sometimes shows different things on different tabs, but other times it changes nothing when I click the tabs. Sometimes I get an error that says I've assigned the sizer to the wrong control with the wrong parent or something, but when I fix that so that the error disappears, the tree stops displaying correctly, if it even did in the first place, which is also iffy.
In any case, I just can't get it all to show up correctly and act properly without errors, no matter what I try, and it seems like I've tried every possible combination, but a working example would be EXTREMELY helpful! Unfortunately, it seems like the entire Internet has VERY little information on wxWidgets, and even less on wxFormBuilder, especially for the controls that I'm specifically using, so it's like I have no way of getting the information I need, because it simply doesn't exist! Does everyone have these problems when using this garbage tool, or is it just me?
Anyway, here's the code that I had initially written:
wxPanel* parent = new wxPanel(this, wxID_ANY);
wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL);
wxNotebook* notebook = new wxNotebook(parent, wxID_ANY, wxDefaultPosition, this->GetSize());
wxPanel* notebookWindow = new wxPanel(notebook, wxID_ANY);
parent->SetSizer(vbox);
Center();
Maximize(true);
notebook->SetSize(this->GetSize());
notebook->AddPage(notebookWindow, wxT("Tab one"), true, 0);
notebook->AddPage(notebookWindow, wxT("Tab two"), true, 0);
wxSplitterWindow* splitterWindow = new wxSplitterWindow(notebookWindow, wxID_ANY);
wxTreeCtrl* tree = new wxTreeCtrl(splitterWindow, wxID_ANY, wxPoint(0, 0), wxSize(200, 1000), wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT | wxTR_HIDE_ROOT | wxTR_EDIT_LABELS);
wxTreeItemId rootID = tree->AddRoot(wxT("Root"));
wxTreeItemId item1ID = tree->AppendItem(rootID, wxT("Item 1"));
wxTreeItemId item2ID = tree->AppendItem(rootID, wxT("Item 2"));
wxTreeItemId item3ID = tree->AppendItem(rootID, wxT("Item 3"));
wxTreeItemId item4ID = tree->AppendItem(item2ID, wxT("Item 4"));
vbox->Add(splitterWindow, 1, wxALL | wxEXPAND, 5);
I was told that I needed to make different windows for each tab, or else it wouldn't change the content when I switched between them, which makes sense, so I changed some things around, and got this:
parent = new wxPanel(this, wxID_ANY);
wxBoxSizer* vbox1 = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* vbox2 = new wxBoxSizer(wxVERTICAL);
wxNotebook* notebook = new wxNotebook(parent, wxID_ANY, wxDefaultPosition, this->GetSize());
wxPanel* firstWindow = new wxPanel(notebook, wxID_ANY);
wxPanel* secondWindow = new wxPanel(notebook, wxID_ANY);
firstWindow->SetSizer(vbox1);
secondWindow->SetSizer(vbox2);
Center();
Maximize(true);
notebook->SetSize(this->GetSize());
notebook->AddPage(firstWindow, wxT("Tab one"), true, 0);
notebook->AddPage(secondWindow, wxT("Tab two"), true, 0);
wxSplitterWindow* splitterWindow = new wxSplitterWindow(firstWindow, wxID_ANY);
wxTreeCtrl* tree = new wxTreeCtrl(splitterWindow, wxID_ANY, wxPoint(0, 0), wxSize(200, 1000), wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT | wxTR_HIDE_ROOT | wxTR_EDIT_LABELS);
wxTreeItemId rootID = tree->AddRoot(wxT("Root"));
wxTreeItemId item1ID = tree->AppendItem(rootID, wxT("Item 1"));
wxTreeItemId item2ID = tree->AppendItem(rootID, wxT("Item 2"));
wxTreeItemId item3ID = tree->AppendItem(rootID, wxT("Item 3"));
wxTreeItemId item4ID = tree->AppendItem(item2ID, wxT("Item 4"));
vbox1->Add(firstWindow, 1, wxALL | wxEXPAND, 5);
vbox2->Add(secondWindow, 1, wxALL | wxEXPAND, 5);
But that caused other problems with the tree not appearing correctly, and so on. Keep in mind that I'm just making a couple of test tabs now, and eventually I'll be making them programmatically, to add as many as needed whenever necessary at run time, but for now, this kind of simple example should work fine, just to get the interface working. But what have I done wrong? Could someone just fix this code to get it to work, also with the nested notebook placed to the right of the tree control, in the right window within the splitter window, PLEASE?! Thank you very much if you can fix this, because I'm desperate!
No posts in this topic were marked as the solution yet. If you can help, add your reply