Some QLineEdit questions - python

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.

Related

How to set a moveable "Add Tab (+)" button to PyQt Tab Bar?

In my program I am using QtTabWidget in which the user can dynamically add tabs as per their needs. I think that the norm of an "Add Tab (+)" Button is now defined by the way we see it in our web browsers like chrome. Which is why I would like to replicate such a button in my program. Please find an example image of what I want my button to look like.
I have found a few people asking this question but not a solid solution to it yet. An example solution is "https://stackoverflow.com/questions/22616446/add-plus-button-to-tabwidget-pyqt4" however the main problem with this is that the new tab button is a corner widget which appears at the top right hand corner of my screen (see image below). Although I would prefer it to be dynamically positioned on the tab bar where it is just adjacent to the final tab that is open.

How to add a "remove button" at the right side of the hovering (or each) item of a wx.ComboBox popup

What I want is a mean to remove an item from the combobox without having to add a separate remove button somewhere else. So I want a remove button to appear at the right side on a combobox dropdown item when I hover over my mouse pointer on it. And, it is also OK if all the items have remove button at the right side and do not need hovering.
The images bellow will illustrate what I am saying [...please ignore my mspaint skils]
[combobox with remove button for hovering item]
https://i.imgur.com/kIMtF3G.jpg
[combobox with remove button for each item]
https://i.imgur.com/iyG23vG.jpg
[NOTE: Sorry, I cannot post images directly because it needs at least 10 reputation to post images.]
[I am new to python and wxpython. So please ignore my ignorance if any. And for the same reason any simple code sample will be greatly helpful.]
Regards.
The wx.ComboBox does not have this feature. The wxPython GUI toolkit uses the target platform's native widgets. If those widgets don't support doing it, then neither does wxPython.
However, wxPython does have custom widgets or you could create your own widget to do this sort of thing.
I also think you could use a context-menu for this task. You would need to right-click to make it work. Another method would be to bind to a mouse event and try to figure out where in the widget you are, but I think that method would be error prone.

wxpython : wrap button label

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

Grab the focus from GTK popup menu

In my python GTK project, I have a popup menu which pop-ups while typing in a particular text area. But, when type a letter popup menu get the focus and I can't type anymore in the text area until I click on the text area and grab the focus manually. I want to keep the focus to the text area as I type regularly while popup menu comes. Can anyone give tell me a way to do this. I tried widget.grab_focus() method. But it didn't solve my problem.
Also I want to know how to set the position of the popup menu. It always appears near by mouse pointer. I want it to appear near by my application.
Thanks all.
I ran into the same problem using the C API, the solution was to invoke the following functions, I presume they're approximately similar to the python equivalents:
gdk_pointer_ungrab(GDK_CURRENT_TIME);
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
gtk_grab_remove(menu);

Popup Dialog in Tkinter/Python

I need to add a popup dialog box on my GUI.
So, when ever I hover my mouse over a label, it should be able to show a popup( Like the type we get while hovering over a file in windows).
It should also disappear as soon i move away the mouse.
To start with, I am not even sure which module or class to use. I tried menu, but the results are not what i expected.
I also tried to learn tkCommonDialog, but couldn't understand it properly.
Please Advice!
The little popup window is called a tooltip.
This post may be relevant: http://bytes.com/topic/python/answers/505848-tkinter-button-overrelief
Take a look at the Balloon widget in the Tix package. I think it is just what you are looking for.

Categories

Resources