I'm developping a text editor with PyQt5 and I want to create my own "title bar".
I've created my own title bar and I have something just like the image above. The only problem is the window's frame. So far I've been using:
setWindowFlags(Qt.FramelessWindowHint)
But I just realised that with this flag there is no frame (cause it's "Frameless") and without the frame I can't resize my window by dragging the border.
I've tried CustomizeWindowHint flag but the title bar is still there, just without icon, name and buttons.
A temporary solution is to detect whenenver the mouse enter the window by installing eventFilter, get its positions, if it's on the border then we have to change the cursor icon (up, left, down, left-up, left-down,...) and if the user drags then calculate and resize window.
Another solution is to set 8 QSizegrip at every corner of the window but we will have to somehow hide those grips and make sure that they don't take any space because we will add 3 grips at the TOP of the title bar so it will be ugly.
But I don't really like these solutions. So is there anyway that I can hide the title bar and keep the frame?
Related
I want to make my Entry box without any color and only shows the cursor so it will blend with the canvas image. Here is what I want to make objective design and here is what I am able to make current design.
I did try the root.wm_attributes("-transparentcolor", "yellow") but it will also make the frame invisible. How do I make the entry box transparent without affecting the background. My code is based on the link below.
https://github.com/ajinkyapadwad/Tkinter-HosoKeys
I am trying to create a GUI as pictured below. So far, I am using 3 frames (topbar, sidebar, and body) as the basics for splitting the GUI up. In the future, I plan to have navigation buttons on the sidebar, and body to give you a better idea of what I am trying to do.
However, I am struggling to figure out how to make the actual frames fill out the whole window when it resized. While I am new to Qt designer, I am aware of the layout feature and I have attempted to utilize it. For example the blue frame with the vertical layout, but this seems to only work on other widgets and not frames. Going back to my example, if I add the vertical layout to the blue part, it will stretch the line edit to fill the entire blue region (I want the line edit to be the size it is now) but it won't cause the blue region to fill the rest of the frame.
Is there a better widget to use for separating the GUI and adding background colors other than the frame container that I am using? Most of the examples I have seen, keep the layouts very basic, and I have not seen one where someone tries to break it up like this.
My work so far
Wire frame that shows what I am trying to do
So in tkinter I'm making a program, I want to know can you make a title box thing like the one in this image with the title "Booking Details"?
Sounds like you want a Label Frame.
The LabelFrame widget is a variant of the Tkinter Frame widget. By default, it draws a border around its child widgets, and it can also display a title.
Ideally, the transparent border.
Here's an example of what i'd like to achieve:
Notice the transparent border.
Now i suppose I could use cairo to create a rectangle with transparency, and put a borderless non-transparent window inside, mimic'ing that effect - which I would if i knew the window would have a fixed dimension. However, if the inner window grows, it'll grow out of the transparent rectangle.
How should one approach such task?
Making window frames is really the job of the window manager (at least under X11, don't know how it works on windows).
But have a look at the GtkBin, GtkBox or GtkMisc widgets. Pack the dialog inside it as a single widget, and use padding to give it a size. Read up on GTK+ drawing model. You will probably need to set a flag and define your own expose-event handler to re-draw your frame.
I have been making a small program with the Tkinter module in python, and I was wondering whether it was possible or not to resize a frame in my program with the mouse. As in, the user can drag the frame border and it will resize itself.
Your use of terminology makes the question unclear. Windows which may be resized by the user are called Toplevel windows. These are what appear as rectangular windows on the display, with a frame around them, typically a title bar, and edges or corners that can be grabbed and resized.
The term Frame refers to a container widget that must be inside a Toplevel or one of its descendents. A Frame has the ability to be resized but you have to write the code to let you interactively resize them. For example, you could place a little grip widget in one or more corners, and writing bindings to the press, motion and release of a mouse button.
Depending on the effect you are looking for, you might want a PanedWindow which is a container that includes a sash that lets you adjust the proportion of space between two other widgets.