How can I create such a pop up window as shown in the image below? What libraries are available for the implementation of such a task?
Important things are:
The triangle at the top of the popup menu
Shadows around the window
The alignment of the window under the call button
Python (pyqt4)
Related
I used TK before but then i had some Problems with Photoimage. In Tk you could easily switch the Taskbaricon and eg. Set the Window Bar to Dark mode. Now i switched to Kivy and now i cant switch neither of them.
Here is the code:
from tkinter import *
root = Tk()
root.geometry("350x350")
root.minsize(250, 250)
root.maxsize(500, 500)
root.mainloop()
When I run this and click the Maximize button (the three buttons on the top right of any program, _◻✖) The window automatically snaps to the top left corner. Is there any way to manipulate this behavior and make it, for instance snap to the center of the screen, or the top right, or the top center?
Is there any way to manipulate this behavior and make it, for instance snap to the center of the screen, or the top right, or the top center?
No, there is not. That button is not controlled by tkinter. That button requests that the window manager set the window to a mazimized state. AFAIK, all window managers define that as the window filling the screen.
You could bind the <Configure> event and check the wm_state() property. If this method returns 'zoomed' then the window is maximized and you could unmaximise it (wm_state('normal')) and reset its position to the screen center using the geometry method.
If you are doing this for a splash-screen or something then this is probably not the right way to go and you should look up wm_overrideredirect or consider making this a toolwindow which does not show a maximize button (root.wm_attributes('-toolwindow', 1)).
I have developed a Tkinter GUI and need to add a button in the GUI window top panel, next to the minimise, maximise and close buttons. The button then calls a function. How can this be done?
Tkinter doesn't have any support to do what you want. You'll have to find some sort of platform-specific library to alter what is shown in the window border.
Your only other option is to turn off the window border provided by your OS with overrideredirect, and then create your own border with whatever controls you want. This requires a lot of work because you also have to write the code for moving and resizing the window, but it's possible.
I'm using python 2.7.5 on OSX 10.8. I'm learning PySide and trying to build a simple GUI.
I managed to use buttons (WOAAA!) used to chose a path or execute functions :
pathBtn = QtGui.QPushButton("FITS file path", self)
pathBtn.setToolTip('Choose the <b>path</b> to your FITS file')
pathBtn.clicked.connect(essai)
pathBtn.resize(pathBtn.sizeHint())
pathBtn.move(200, 100)
My problem is, when the program is running and I change the size of the window with the mouse cursor, the buttons don't move, don't adapt to the size variation.
I tried to find some answer (hell yeah google) and I understand that "QVBoxLayout" should do what I want (some kind of "dynamic" positionning, don't know if there's a specific name for that), but I didn't understand its syntax nor how to use it...
Any help appreciated!
In Qt widgets, layouts and the widget's size hints determine how things resize. The general procedure to layout a widget would be (for example):
dialog = QDialog()
layout = QVBoxLayout()
label = QLabel('This is a label')
edit = QLineEdit('This is a line edit box')
layout.addWidget(label)
layout.addWidget(edit)
dialog.setLayout(layout)
(*I cannot test this code here at work (no Qt/PySide), so consider this "pseudo code" :-)
This results in a dialog widget with a label and an edit box. If you resize the dialog widget, the layout and the resize properties of the widgets ensure that the label and edit box resize appropriately: horizontally both expand maximally, but vertically the edit will keep the same size while the label takes all the remaining space. This is because the resize hint of the edit box says it wants to keep its height (namely, one line of text).
If you do not specify a layout, your widgets (buttons, labels) don't do anything whenr resizing their parent widget, which is what you are observing. Hence, the solution is indeed the QVBoxLayout, use it as I described above.
By the way: for more complicated layouts, you probably want to use the Designer tool provided with Qt: this tool lets you see and test your GUI a priori.
Is there any way to get a border like this in Tkinter? Notice how it lacks the buttons on the top right. Also I don't want this program to show in the task bar.
This is in windows 7, btw.
Tk (and thus, Tkinter) has a command for removing all window manager decoration. This command in tkinter is the "wm_overrideredirect" method of toplevel windows. Pass it a parameter of True to remove the window manager decorations. You can then draw whatever borders you want, usually by packing a canvas over the entire window and drawing on the canvas.
However, when I experiment with this on my Mac, the window appears properly but won't take focus. Perhaps this is a bug in Tkinter. I don't see the same problem with identical code in Tcl.
The WS_DLGFRAME window style should give you a window without a titlebar and WS_EX_TOOLWINDOW is normally also used for a window like this so it is not visible in the taskbar (Or with a hidden parent window like control panel dialogs before Vista) You can figure out the exact window styles with a tool like Spy++ (Visual Studio) or WinSpy++