Remove the size request of a widget (Python, Gtk3) - python

I want to fit some text in a label. I almost managed to do it: when I enlarge the window, I add some <big> tags to the label and the text enlarges with the window. But if I try to shrink the window, the size-request of the label doesn't let me do it.
The label is updated many times a second, so if I try to set a custom size request every time I apply a new label, the window will shrink and enlarge if i try to shrink it.
What I want to do is removing the size request, without word wrapping and other things like this: I just want let the label go out of the window.

Set the "ellipsize" property of label to True.

Put the label in a container like GtkScrolledWindow.

Related

Automatically resizing a guizero window

I have written a guizero code that creates a new window with different amounts of information on it depending on what is selected. I was just wondering if there is a function to resize the window to fit all of the information. I am currently just making the window big enough to fit the largest amount of information but I would rather have it so it resizes it automatically.
And also is there a simple function so that if the window size is changed all of the widgets inside of it change size as well?
I think is not possible to automaticly resize the window but you can count the number of lines and resize the window.
numLines*defaultHeightByLine + height of the other elements

How to replace text in label with an image in kivy?

Is it possible to replace text in label with an image in kivy?
I have a label containing a text but i want to replace the text with an image.
Is this possible in kivy?
The answer is technically yes, but this isn't something exposed by the label api so you'd have to mess about doing stuff manually. It would probably be a better idea to put an Image on top of (or behind) the Label, and use this to display the imgae when necessary.

Tkinter - scale all components on resize?

Is it possible that when a Tkinter window is made bigger or larger, everyhting in the window is scaled?
So all the proportions stay the same but their sizes vary.
Now when the window is resized all the buttons etc stay the same so I disabled resize because there is no point, it just looks bad.
No, it is likely not possible, depending on what you mean by "everything" and what you mean by "scaled". Any widget can be made to stretch to fill its allotted space. Text widgets and canvas widgets, for example, scale nicely. A button or label will fill the space it's in, but the text inside the widget won't change (that is also true of text and canvas widgets).
It's possible to organize your GUI so that when the window resizes, everything remains in its proper place at its original size. Having buttons that automatically scale is not something most people would expect. Disabling resizing usually results in a poor user experience -- users should have the ability to make a window larger or smaller.

Automatic layout when widget space is finite in Tkinter

I am trying to achieve the following effect using a Tkinter python app:
The user can define a finite number of list elements, aka categories.
I then would like to present these categories next to each other, based on the following approach:
l=Label(self.body,text='Category: ')
l.pack(side=Left)
for i in range(0,len(self.categories)):
l=Label(self.body,text=self.category[i])
l.pack(side=LEFT)
self.body.pack(fill=BOTH)
Of course, this does not work. Is there an elegant way to "wrap" a whole label at the widget borders?
Thanks!
You have to know the size of the frame you are using to pack the labels into, and the width of the label. You can set the width parameter for the label, but it uses a size that depends on the font used i.e. the same "width=" results in different label widths for different font sizes. So it can not be done with the code you posted. Link to label parameters http://effbot.org/tkinterbook/label.htm

Allow a ToolItem to fill horizontally in a Toolbar

SO.
I've been busy working on a project in python and pygtk. I want to have (at the top) a "Toolbar" with back, forward etc. buttons and a long Entry that would take the rest of the horizontal space. I don't get the desired effect, however, as the space the Entry takes is quite limited.
self.omnicont = gtk.ToolItem()
self.omni = gtk.Entry()
self.omnicont.add(self.omni)
I've tried set_child_packing (which doesn't apply to Toolbars, it seems). I couldn't find any other way.
The buttons I have are declared in this way:
self.bBack = gtk.ToolButton(gtk.STOCK_GO_BACK)
and similar, so I don't think it's possible to put buttons like this in an HBOx.
How can I have the Entry take all the available horizontal space and, if that's not possible, how could I get an HBox to contain buttons with the stock icons?
Accordingly to the docs you can use:
set_expand(True)
on the item you want to expand.

Categories

Resources