kandi X-RAY | wxapp Summary
kandi X-RAY | wxapp Summary
wxapp
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of wxapp
wxapp Key Features
wxapp Examples and Code Snippets
Community Discussions
Trending Discussions on wxapp
QUESTION
I want to handle files in a cross-platform application using wxWidgets 3.1. I rely on some functions that only accept the file name as an std::string
.
On Windows, I can simply use wxString::ToStdString()
and everything is fine.
On Linux (Ubuntu 20.04 LTS), the conversion fails and returns an empty string when there are "special" characters in the file name or path (e.g., the default downloads directory on a French Ubuntu "Téléchargement").
When I specify the following converter explicitly on Linux, the conversion succeeds: std::string str = wxs.ToStdString(wxMBConvUTF8());
But this does not work on Windows and scrambles the "special" characters.
I guess, I could write platform-dependent code to deal with this, but that defeats the purpose of the toolkit.
I have done quite a bit of research on this but I am utterly confused now. I thought wxString
uses std::string
under the hood in a Unicode wxWidgets build (which I am using)? Why is this (apparently) platform-dependent? What am I missing?
Here is a minimal example that will pop up three messageboxes: The first one shows the wxString
correctly, the second one shows no string (because the conversion fails), the third one shows the string once the conversion is done explicitly. On Windows, the first two boxes show the string correctly and the last one shows the wrong characters for the two 'é'.
ANSWER
Answered 2021-May-27 at 08:16You should be using wxString::fn_str()
, which returns a suitable string in a suitable type to be used as a filename.
If you use wxString::ToStdString()
on Windows, everything is no longer "fine" if you have e.g. cyrillic letters in the string and your locale is German. The conversion fails.
QUESTION
I'm currently migrating from wxPython 4.0.7 to wxPython 4.1.0. This changes the wx version from 3.0.x to 3.1.x.
Tl;dr:
Using a wx.ListCtrl
I sometimes get an error when I call event.Skip()
inside a wxEVT_SIZE
event handler. To Skip()
or not to Skip()
? (i.e. whats the default event handling for a wxEVT_SIZE
and do I need it?)
Long Version:
Using wx.ListCtrl
with event.Skip
inside the wxEVT_SIZE
handler produces an error in some of my forms (so I think there must be more to it). Now, I couldn't strip any of the occurrences down to have a minimal example, since the error kinda disappears randomly when I remove (seemingly) unrelated parts of the code. The error even disappears (sometimes) when I replace a long label with a shorter label. However, changing the Frame or Panel size doesn't change anything.
Here is, what I found out:
- The error is definitely linked to the usage of the
wx.ListCtrl
class - The error only occurs, when a function is bound to the
wxEVT_COMMAND_LIST_ITEM_ACTIVATED
event, though an empty handler (with or withoutSkip()
) is enough to provoke the error. - The error only occurs when a function is bound to the
wxEVT_SIZE
event - The error only occurs when I call
event.Skip()
in thewxEVT_SIZE
handler
It seems like I can simply remove the event.Skip()
call inside the wxEVT_SIZE
handler and be done, but the relevant C++ Code seems like there is more going on.
Here is the error (note: the error does not crash the wxApp):
...ANSWER
Answered 2021-May-12 at 11:09I believe this assert can only be triggered if a handler calls Bind()
from its event handler, but skips the event, i.e. pretends that the event wasn't handled at all. In an ideal world, this should be possible and I think the assert is actually over-eager and needs to be relaxed, but for now, if you really need to do it like this, you must either:
- Postpone calling
Bind()
by usingCallAfter()
. - Or avoid calling
event.Skip()
.
(note that the assert won't be always triggered in this case, you also need to delete a handler that was previously connected to the same object shortly before).
But generally speaking you should call Skip()
unless you have fully processed the event and don't want any other handlers, either those in the base class or the built-in ones, to run after yours. For wxEVT_SIZE
it means that you've performed the re-layout of the window yourself and don't want the base class to do anything. So the solution (1) is better because it can be used even if you do want the base class handler to run.
QUESTION
I'm using wxPython FlatNotebook widget and have enabled the FNB_X_ON_TAB style. But what bind event triggers on this action (clicking the x in the tab to close it)?
...ANSWER
Answered 2021-May-07 at 08:36You are forcing the widget Id
in the Bind
command, to be 100.
But nothing has been set to an Id of 100.
You have options:
- Set the notebooks Id to 100
- Leave the Id out of the Bind, assuming you have only 1 FlatNotebook
- Get the Id in the Bind
- Bind to the widget not self
So:
notebook = fnb.FlatNotebook(panel, 100)
self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CLOSED, self.popup_close_tab)
self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CLOSED, self.popup_close_tab, id=notebook.GetId())
notebook.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CLOSED, self.popup_close_tab)
It's a pretty flexible system, however serendipity had left the building, when you made one of the few choices, that wouldn't work. :)
QUESTION
I'm relatively new to both C++ and Wx, so I've been doing a lot of blundering around trying to get this to work over the past few hours, but I seem to have hit a figurative brick wall with this issue.
This code compiles with no errors, but when run, it does nothing. It simply remains running until terminated (e.g. with Ctrl-C), but a window never opens.
Here is the C++ source:
...ANSWER
Answered 2021-Apr-27 at 11:26Your MainFrame
gets destroyed when you reach the end of the function, which is not at all what you want for a frame which is supposed to exist for a long time. The simplest correct thing to do is
QUESTION
I am making a series of applications on physics simulations and until now I've done some of them using purely the handy SFML library. Now I want to add some GUI elements to them. I am just a little bit familiar with wxWidgets framework and wxFrames but have no idea how wxDc works, which seems to be at the core of SFML-wxWidgets integration. I will list my queries one by one.
- My shot at the old tutorial provided by SFML dev webpage: The final code, after correcting for the trivial errors looks like this:
ANSWER
Answered 2021-Apr-19 at 16:11Your error is due to using DECLARE_EVENT_TABLE
but not using any wxBEGIN_EVENT_TABLE/wxEND_EVENT_TABLE
, i.e. you never define your event table nor connect any event handlers.
I don't know anything about SFML, so I can't really help you with the rest, but apparently drawing is supposed to be done from your wxEVT_PAINT
handler -- once you connect it -- by just calling sf::RenderWindow::Display()
.
QUESTION
I have been trying for a while to get the wxWidgets library working on my Mac, but I have been having tons of issues. I have tried both downloading the source and building it myself and using Homebrew.
I have gotten to the point where I can compile the following:
helloworld.hpp:
...ANSWER
Answered 2021-Mar-21 at 00:39@scriptor6,
Get rid of homebrew install.
Get rid of the one you compiled
Download latest release of the library from wxwidgets.org/downloads.
Unpack it somewhere.
Do this
QUESTION
I'd like to use wxTimer in my application, but I don't want to use the preprocessor macros to bind the events. Instead I want to use Bind()
during the CTOR call to bind the events to my ui elements.
After binding my timer, it doesn't start or it doesn't call the event handler. According to this it ought to work like I want to. I also do not want to use Connect()
. Binding a button in the same way works just fine. Here is a minimal example:
minimum example:
...ANSWER
Answered 2021-Jan-25 at 23:56You should change
QUESTION
I'm new to wxWidgets and I wanted to make a simple GUI application (on ubuntu) for reference.
I created a simple window, added some buttons and in a button event handler I want to update a wxStaticText
object's text on screen to indicate which button has been pressed.
However when I call the SetLabel
or SetLabelText
functions that wxStaticText
inherits, then I get a segmentation fault.
Maybe I'm missing something and wxStaticText is just not able to have their label set and I need another control. But I couldn't find anything like that in the class list.
I'm using wxWidgets 3.1.4 from the codelite repositories.
MainFrame.cpp
...ANSWER
Answered 2021-Jan-22 at 22:07It's difficult to see because there is too much code here (you should try to reduce your examples as much as possible, by removing all the unrelated parts), but the root cause of your problem is this line:
QUESTION
I have got a class named cApp
.
I want to run CheckProcessList()
in the background until the program terminates. So i thought, well, lets run it in a detached thread until ~cApp()
. I made a bool to break out of the loop in CheckProcessList()
. In ~cApp
I set the bool true m_bTerminateThread = true
to break out and wait for the promise m_barrierFuture->wait()
that the thread has ended execution. After breaking out i set the promise barrier.set_value()
that the thread is now ending execution. Now ~cApp
can finish execution. Or at least that is my understanding of the things i want to achieve and how to do it. Well, can't be right since i get Compiler Errors.
Why did it want to check if the thread finished in the first place? Because the program breaks at runtime when it terminates and the thread is at that moment in GetProcId()
. If it is sleeping in the moment of termination the program does not break.
I searched msdn and stackoverflow for answers but i do not get anything out of it that i can understand. I am using VS2019 and C++14. Thank you guys in advance.
...cApp.h
ANSWER
Answered 2021-Jan-08 at 23:54m_tCheckProcList = new std::thread(&cApp::CheckProcessList, std::move(barrier));
I don't know to which lines your errors pertains (you didn't show this) but I suspect at least above statement is wrong.
If you pass an address of a thread procedure to std::thread
constructor and this procedure is a non-static member function the next argument after must be an address of the object you refer to (after all a non-static member function must have an instance that it is called on behalf of). std::promise
is not a type which contains such a function pointer type &cApp::CheckProcessList
so this cannot work.
If you want to associate that thread with the object that creates it typically such invocation looks like:
QUESTION
I'm trying to create a multithreaded wxWidgets application using the wxThreadHelper mixin. I'm working on Windows, but the whole idea was to be platform independent. I'm basically following the online examples, but there must be something I don't understand, since as soon as I call the Delete()
function, the application hangs, waiting forever. The problem is that it appears that the secondary thread hangs also. Do you have any idea on what is it that I'm missing?
This is as minimal as I could get:
...ANSWER
Answered 2020-Dec-19 at 23:51There are many issues here. To answer the main question of why this hangs your program, in the OnClose
method you call Destroy()
and then delete the frame (which includes m_text_time
). Meanwhile, your thread is sleeping and when it wakes up, it will try change the label for m_text_time
which no longer exists. I'm not sure why this causes deadlock instead of a segfault, but this is the problem. So you can make this work poorly and problematically by simply changing the order to:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install wxapp
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page