wxpython : wrap button label - python

I am developing a wxPython GUI application where I need to create a Button label of big string - like "Change the Address"
The issue is that the button label does not gets wrapped and button size expands which is not the intention.
Is there any way we can wrap the button label around the button which is of specified size?

You shouldn't make buttons with long labels to begin with. Buttons are not supposed to have long labels. Use a TextCtrl or a StaticText instead.
However, if you really, really want to do this, try inserting line breaks into your strings. In Python, you would do this:
label= "Change the\n Address"
This works on Windows anyway with wxPython 2.9

Related

Better Method of Creating Multi Line Text Entry?

I need to create a message box for a user in a GUI with tkinter. For 3/4 of my entries, Entry(master, options. . .,) works. But for a message box, I need a multi line entry.
How would I do this? I tried ScrolledText(root).pack(), but it doesn't have the same commands/variables as Entry.
It is not explicitly mentioned in the documentation, but even if the tkinter.Entry widget's content can be scrolled, it can only be scrolled horizontally meaning that you can not use the yscrollcommandoption unlike with Canvas, Text and Listbox widgets.
This means technically your goal is not feasible, I mean you can not write multiple lines inside an Entry widget so that you scroll them vertically but only horizontally:
(if you need the code of this screenshot, please let me know).
Billal is right, however i would recomend simply using a Textbox.
go to: http://www.tutorialspoint.com/python/tk_text.htm
for more information

Add a scrollbar to a Tkinter Label?

I was wondering if I can add a scrollbar to a Label or not?
I followed this tutorial to create a simple terminal GUI with a Button and a TextField. The problem is that, unlike what's in the tutorial , I need my Label to contain more than just a single line
Any alternatives? I want something exactly like this tutorial, but with more lines and a scrollbar for the Label (I already limited its size, but no scrollbar).
You cannot add a scrollbar to a Label.
If you want multiple lines of text that can be scrolled, use a Text widget.

pyGTK : pack and unpack

Can I use pack once the main loop has been showed, or should I use something else to add /remove widgets to /from a vbox afterwards ?
I have this gtk.Window() that contains a vbox, where a menu, a treeview and a button are packed. At the push of this button, I want to display an image in a new container inside this window / vbox, and ideally, close said container at will.
(think image viewer with a file list, you click on an image file and a pane opens displaying it, if you click on another image file the new image is displayed in place of the old, and you can close the image pane)
My question is : How do you do that ? My trials so far led me to believe that once the vbox has been show()'d, you cant pack anything else into it..?
Has the "image" container have to exist prior to being displayed...?
What is the proper process to do this, in witch direction of the GTK manual should I look?
In GTK+ all widgets are hidden by default (which I think was a stupid design decision, but oh well). You usually call show_all() on a window, so indirectly show all widgets contained in it by the time of the call. If you add (pack, whatever) a widget later, don't forget to show() it manually.

Some QLineEdit questions

I'm using Python with PyQt and I have a few problems with my QLineEdits.
First of all, I want to put text on them, but not the regular one, I mean the transparent text that disappears when you click on the QLineEdit.
How can I disable clicking on my QLineEdit?
Pretty much like this:
linedit = QtGui.QlineEdit()
linedit.setPlaceholderText("My grey text which disappear when I click on it")
linedit.setEnabled(False)
with Qt minimum version 4.7 and latest PyQt 4.

Selecting Widgets

In Tkinter I'm trying to make it so when a command is run a widget is automatically selected, so that a one may bind events to the newly selected widget.
Basically I want it so when I press a button a text widget appears. When it appears normally one would have to click the text widget to facilitate the running of events bound to the text widget. I want that behavior to automatically happen when the user clicks the button. So that one does not have to click the button and then the text widget, but simply the button.
I'd also like it so if one started typing after the button was pressed it would automatically start filling the text widget. Again to cut out having to click on the text widget.
What bit of code does the above?
The terminology which describes what you want is "focus" -- you want to set the keyboard focus to your text widget. To do that you need to use the focus_set() and/or focus_force() methods on the text widget.

Categories

Resources