Does anyone know of an example where it is shown how to drag a button from one panel to another in wxPython?
I have created a bitmap button in a panel, and I would like to be able to drag it to a different panel and drop I there.
I haven't found any examples using buttons, just text and files.
I am using the latest version of Python and wxPython.
If you want to graphically represent the drag, one good way to do this is to create a borderless Frame that follows the mouse during a drag. You remove the button from your source Frame, temporarily put it in this "drag Frame", and then, when the user drops, add it to your destination Frame.
Related
I don't know How structure the GUI of my program...
I don't have big experience with GUI programming, i know all the widgets, the
geometry managers, the "object-oriented" method in Tkinter, but i don't understand
how combine all this things...
I want to create a program with an image in background where there is a button and if i press this button i switch in another page and the button disappears
Like this : https://moqups.com/iampirla#gmail.com/wyM7CyET/p:a80e8d902
How i can structure my code to do this?
You could use pack_forget() this removes the widget although allows you to use it later if you wish. You could do the first page and then use some code like below. To clear the page. This could then reference the next thing you wish to do using in this example question().
def answred():
nameLabel.pack_forget()
nameEntry.pack_forget()
nameButton.pack_forget()
classQuestion.pack_forget()
button1.pack_forget()
button2.pack_forget()
button3.pack_forget()
question()
You could this but not remove the background widgets
I have a tkinter GUI that, when opened, is an empty widget with a menu bar on top. Clicking on the options on the menu causes for text boxes, more buttons and more menus to appear in the widget. My problem is that everything overlaps.
I need an easy way to delete everything that is currently there, like a "clear window" option.
I've tried packing everything into a frame and then destroying a frame but, for some reason, it's not working.
Any suggestions?
Ideally, I would make something that checks to see if there is anything (button, text box, menu) in a designated space, and it would delete it all before creating the new widget attributes.
The Problem I was having was fixed by creating a new frame within each function and having the code destroy any previously existing frames with Frame.destroy().
My second problem, where widgets within my frame were not, appearing was being caused by how Tkinter frames automatically resize to fit the original widgets. Therefore, when I added widgets to the frame, the frame remained the size of the first widget and didn't show the new buttons. I used frame.pack_propagate(0) to force the frame to remain the specified size.
I have a frame which I use as the main form (mainFrame), it inherits from mainFrameBase, which inherits from wxFrame.
It has a "close" system button. When it is pressed the app shuts down. All very much to my liking.
I inherit another frame from mainFrameBase (progScreen). When a button is pressed, the progScreen is shown. When I click its system close button, the form does not close.
What I want to achieve with this setup is that you can click a button on the main frame and a slightly different view of the main frame is shown to allow the user to "progam" certain buttons.
By the way, I'm using WXFormBuilder (excellent program) to create the screens.
What I would do is create two panels with the controls you want, one for the regular screen and one for the programming screen. Then when you want to switch, you hide one panel and show the other. That way, both screens are contained in one frame that when closed, exits the program. I actually have a tutorial that is similar to this here:
http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/
Hope that helps!
I'm developing an application that contains a number of panes. See the screenshot:
The left settings pane is a wx.ScrolledPanel that contains a number of wx.Panels.
The top events pane is a wx.grid.Grid.
The bottom data pane is a wx.Panel that contains a wx.grid.Grid.
The middle plot pane is a wx.Panel containing an enthought chaco plot.
The right detector pane is a wx.Panel.
I would like to implement focus follows mouse so that when I move my mouse over the plot I can immediately zoom in or out using my scroll wheel without first clicking on the plot to give it the focus.
Similarly when I move my mouse over the left settings , the top events or the bottom data panes I would like to be able to immediately scroll the window using the scroll wheel without first clicking on the window.
Currently I defined a function:
def focusFollowsMouse(window):
window.Bind(wx.EVT_ENTER_WINDOW, lambda event: window.SetFocus())
I would like to apply this function only on the four top-level panes: plot, settings, events and data.
However I need to call this function for each sub-panel or control in each of the top-level panes to get this to work. For example I need to apply this function individually to the Measurement Settings, Analysis Parameters, View Settings etc. panels.
Most likely the EVT_ENTER_WINDOW event is not propagated to parent windows.
Is there a way to get this to work without applying focusFollowsMouse to each and every sub-panel or control?
Thanks
This is Windows' behaviour - it works as you expect under GTK. Personally, I'd leave your app as it is, for consistency with other Windows applications, and install WizMouse
I would like to have my pyqt aplication have tabs in the menu bar like Google Chrome :)
Any suggestions or a simple example on how to do it?
I did find these relevant link:
- http://ivan.fomentgroup.org/blog/2009/03/29/instant-chrome/
You have to use the Qt.FramelessWindowHint for that, and then create your own Max, Min, Close buttons as Widgets and add them there. I have a good working toolkit for these types of softwares: http://traipse.assembla.com/spaces/ghostqt
In your case you should reclass the resizeEvent so you can change the flags. If the window is maximized you will not need to worry about moving it around, but if it is not maximized you can remove the Qt.FramelessWindowHint flag and get your title bar back; just like Chrome does.
Is that what you are looking for?
If I understand correctly, just create a QWindow that contains a QTabBar widget(and not a QMenuBar, or simply use a QTabWidget as your main program widget.
you need to do the following:
remove window border (FramelessWindowHint)
Implement your own window moving and resizing code
Insert tabbar on the top, and add buttons for close etc. to it (or create a frame that will contain the tabbar and buttons)
And that's all that was done in Webbie (the link you provided) :)