I have the following problem, you may help me with:
There exists a GUI, that was created with Glade. The window contains multiple items of the type Gtk.TextView.
My intention is to change the background color of one of these items after clicking on it. Each item is connected with a signal, that is fired to change the color.
The change of the color works fine, because what i get over the widget argument is the expected Gtk.TextView.
The next step I do, is saving the name of the widget gained through get_name() into a label for later use, because as soon as I click on another item the last one should be reset to the former color. Unfortunately, when I want to get this (former) item - using get_object()-Method from Gtk.Builder and saved name as parameter - I get an object of type Gtk.TextBuffer. Now, there is the problem that TextBuffer has no modify_bg/base facility - and no option to change the color.
Is there any way to trace back a TextBuffer's TextView?
Thanks in advance!
Regards
Related
I'm working on a code that has a QWidget inherented menu object containing QPushButton inherented button objects. I want to add sub-buttons to some of the buttons, that appear upon hovering on their parent button. The problem is that when I hover on the parent, I get the following error from my logger every time I move my mouse.
qt_message_handler: line: 0, func: None(), file: None
DEBUG: QPainter::begin: A paint device can only be painted by one painter at a time.
qt_message_handler: line: 0, func: None(), file: None
DEBUG: QPainter::translate: Painter not active
Unfortunately, that doesn't hand over a lot of leads.
Only the menu object makes use of the paintEvent() function (with only one QPainter), and update() is only called once in the code. The errors don't appear to come from in or around that code. Or any other particular function - I tested every function by printing something at the beginning and end and checked if the logs appeared in between, but that never happened.
I tried messing around with QPainter.begin() and end(), but that didn't go anywhere either.
PS: I would like to post a code snippet, but I can't seeing as there's no particular part of the code - and posting the entire thing wouldn't make much sense either.
I am trying to adapt this working example from here that used tkinter to give auto-completion results based on input of the user. When I run the program and fill in some characters, e.g. 'a', I want to automatically have the first entry of the list selected and use my down arrow to scroll further down that list. I have not managed to adapt it to achieve this as no matter what key-bindings I try, it does not focus on the auto-completion result list.
The only way I can actually scroll down with the arrow keys is by using Command+Down on my computer. I have no idea what this is doing internally as even binding Command+Down in code does not give the same behaviour (gives a ? sign in text field). Therefore, my question is: how can you bind the down arrow to scroll through the auto-complete list (Listbox)?
I hope you can help me out on this.
I programmed a dot probe paradigm using the Standalone PsychoPy v1.80.03. After the dot probe I need a modified task that looks identical to the dot probe. I therefore pass the dot probe object in the 2nd task's constructor to re-use the window and the stimulus containers bound to this window.
Before the 2nd task starts I, however, need to input some information (e.g. the condition) using a gui.DlgFromDict. With the window from the dot probe still in fullscreen, the Dialog Box cannot be reached.
I tried to change the fullscreen to false by dotProbe.window.fullscr = False followed by a dotProbe.window.flip() but once the window is instantiated, changing this attribute doesn't seem to have an effect.
Closing the window with dotProbe.window.close() makes the Dialog accessible but there is no function that opens the window again to proceed in the 2nd task. Of course I could just construct a new window but as I said I need the identical setup with the stimuli at the exact same positions and all other parameters alike. Copying all parameters from one script to another to "manually" ensure them to look identical is undesired - as are workarounds like providing the input for the 2nd task prior to the dot probe since the scripts should be able be run independently (if no dot probe object is provided in the constructor, a new one is created to provide the default look).
Thanks for any help!
You don't want to close the window: that actually destroys the entire object, along with all of its stimuli and other attributes.
A solution to a similar problem was posted here: https://groups.google.com/forum/#!msg/psychopy-users/zq2E12vnYiI/6mXirJMlq3cJ
According to Jan Kramer there (and a subsequent improvement from jashubbard here: https://discourse.psychopy.org/t/bug-user-defined-gui-does-not-display-in-full-screen-on-mac-osx/2214/3), I think you want to use something like:
win.winHandle.minimize() # minimise the PsychoPy window
win.winHandle.set_fullscreen(False) # disable fullscreen
win.flip() # redraw the (minimised) window
This will hide the window away rather than closing it. Then restore it with:
win.winHandle.maximize()
win.winHandle.set_fullscreen(True)
win.winHandle.activate()
win.flip()
I am using a SearchCtrl with a dropdown menu and I'm having some trouble with the events. When I click the little arrow next to the search button, the EVT_SEARCHCTRL_SEARCH_BTN is triggered, which is not what I want. I only want the EVT_MENU_RANGE to be triggered after I clicked an item, and not also the EVT_SEARCHCTRL_SEARCH_BTN before i click it.
self.search_ctrl = wx.SearchCtrl(self.panel_1, -1,
style=wx.TE_PROCESS_ENTER)
self.search_menu = wx.Menu()
self.search_items = {"text1":"value1", "text2":"value2"}
for txt in self.search_items:
self.search_menu.Append(-1, txt)
self.search_ctrl.SetMenu(self.search_menu)
self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.search, self.search_ctrl)
self.Bind(wx.EVT_MENU_RANGE, self.onSearchMenu)
Although I should probably add id's to the menu bind, this isn't causing the problem. The code works as expected when I comment out the search button bind.
UPDATE
Apparently this isn't a problem, but a 'feature' of the searchctrl. I tried the wxpython demo and the menu also showed up if I just clicked the search button, and not the arrow. It is apparently one button, instead of the two i thought it was.
Is there a way to accomplish my original request? Do i have to manually modify a textctrl, or is there an other solution?
All the examples I've seen suggest you need to specify a range of IDs when you call your menu bind.
Maybe by default it binds to something unexpected... ?
Edit - In light of your update, it seems likely that you're going to need to make a custom control to me..
I'm using PyGObject but I think this is a question that could be adapted to all GTK, so if someone know how to do it using C or anything should work in python also.
I have two treeview, Active and Inactive, I load data from a Sqlite database and I can swap and drag & drop items from one to other.
This is just an aestetic thing, if I click on one item on one treeview I want that a previous selected item on the other be deselected.
It appears that nobody had to do something similar because I didn't found anything about it on the net.
At the risk of being too basic (perhaps I misunderstand the problem), to manipulate treeview selections, you use the GtkTreeSelection object returned from GtkTreeView.get_selection. You can attach to signals on this object, change the current selection,etc.
To turn off selection in the other view, you can get its selection mode property and set to GTK_SELECTION_NONE. To turn it back on upon clicking, my thought was that you could catch a grab-focus signal, set the selection mode to single in that view, and set the selection mode to none in the other view:
(connect view-1 'grab-focus
(lambda args
(set-mode (gtk-tree-view-get-selection view-1) "GTK_SELECTION_SINGLE")
(set-mode (gtk-tree-view-get-selection view-2) "GTK_SELECTION_NONE")))
(That code is using the guile-gnome wrapper but the concept should be the same in any language binding.) A problem with this approach is that now in order to make a selection you must click the tree view twice - once to grab the focus, and again to make the selection.