I'm creating a simple GUI menu with 2X3 ImageButtons using PyQt4. It should look like this, except there should be images instead of text:
I followed this tutorial: http://popdevelop.com/2010/05/an-example-on-how-to-make-qlabel-clickable/
for creating image buttons out of QLabels and I put them in grid layout.
It works fine, but my problem is that my application is supposed to be used using keyboard arrows (without mouse), so I want to make visible which label is focused before being selected.
Is it possible to do in PyQt? Thanks in advance
One way of capturing keyboard events is done by installing an event filter in your app with installEventFilter ( QObject * filterObj ) and then filter with something like:
if event.type() == QEvent.KeyPress:
print "Key pressed!"
Related
I recently noticed the following popup message ("6 occurrences replaced") in Qt Creator (3.4.2).
I like its style and want to use it in my own application. But how is it done? Is this a particular widget or what else? Can someone point me in the right direction.
You could create your own window with round corners like that with text in the middle paid show it when you want too make the window so it takes a parameter text and you can add different text each time and show
I'm trying to write a kiosk GUI in ruby/gtk on ubuntu. I'm pretty fluent in ruby, but new to writing GUIs and not great with linux.
I'm using a touch screen, and am using our own images for buttons, e.g.
button_image = Gtk::Image.new(Gdk::Pixbuff.new "images/button_image.png")
#button = Gtk::Button.new
#button.add(button_image)
#button.set_relief(Gtk::RELIEF_NONE)
My issue is that when the buttons are pressed or remain selected (or hovered over, although this is less relevant with a touch screen), gtk shows fat, square borders around them. Obviously it's applying gtk's prelight / selected / active lighting to the buttons. I've tried changing the button properties in various ways, and also tryied hacking apart my theme, and while I can modify how the highlighting looks, I can't seem to completely get rid of it. Changing the color of the highlight via my theme is easy, but if I remove my setting there's still a default I can't get rid of.
Does anyone know if there's a way to stop it, or possibly make it transparent? Thanks in advance!
Sounds like you want to use exactly your image for the whole button, instead of putting an image inside the normal GtkButton - but still use all the normal behavior of the button.
The easiest way to do this is to just override the drawing. If you are on gtk2, connect to the "expose-event" signal, do your drawing there, and return true so that the default handler doesn't get run. If you are on gtk3, connect to the "draw" signal and do the same.
I tried meddling with the drawing as Federico suggested, but found that the most direct way to address this was instead to use an event box rather than a button. Event boxes accept clicks just like buttons, but don't respond to selecting, hovering, etc. In ruby, the code looks like this:
image = Gtk::Image.new("myfile.png")
event_box = Gtk::EventBox.new.add(image)
event_box.visible_window = false
event_box.signal_connect("button_press_event") do
puts "Clicked."
end
Most of this is exactly like a button; the *visible_window* method, obviously, keeps the event box from being visible under the button image.
In the bing maps app on windows phone, when I click the search button I get a search box sliding in from the top of the screen, and the keyboard sliding in from the bottom. I want to achieve the same behaviour in my own windows phone app (based around a bing map control).
I will want a few drop-in boxes, such as for setting up a filter (which will need a few check boxes and text entry), and adding an item (which will require a text entry for the name, and ideally still allow the map in the main panel to be panned to fine-tune the location of the item).
I'm pretty sure the keyboard comes up automatically when a textbox gets focus, but I'm not sure what might be the best approach for dropping in the search box. It looks like it would need something with storyboards/animations/projections, but I haven't found a clear standard approach so far, and I want to make sure I do it the right way from the start (as I don't really have time to do it twice).
Is there a standard/best practice way to achieve the effect?
Yes, and you don't need a single line of code. You can express the whole animation using XAML. Get a text on Silverlight and read the chapters on animation with particular reference to storyboards and Easing.
On the IPhone, the map control allows you to switch between a list mode and map mode easily. I've been trying to find examples of this for WP7 but am at a loss.
Is there a best practice for implementing a list of objects on a map?
If not, do we just do it manually, I.E. Save the dataset and display it as a listbox or something?
If you do it manually, where is the best place to put a button to switch you between the 2 screen styles? I feel like that app bar isn't right.
I don't want to copy the IPhone UI standard and have a button in the title bar, although I'm running out of options.
For one "best practice" I'd take a look at how the default Bing Maps app works - it provides a "results list" text menu item accessible from the ApplicationBar - and this is displayed via a full screen dialog (at least I think that's what it is).
However, that is only one "best practice" - I don't think their UI is perfect for all apps.
Application bar is fine, just make sure the buttons are in the same positions for each bar and that toggling views 10 times does not require pressing Back 10 times to go to the previous page, maybe use a different page transition so it doesn't feel like every other transition on the app.
I'm making a simple Qt application. It has 4 screens/pages:
Start import
Select folder to import images to
Accept or reject each image in folder, and when no images left:
"No images left" and an OK button.
I can't figure out the best way to implement this. I started off with a QWidget, but this quickly got unmanageable.
Is a QWizard too constrained?
EDIT: Part of the problem with QWizard is it seems to always have "Back" and "Next" buttons. I don't want those as options in this program, so this leads me to believe that a wizard isn't exactly what I'm after.
I'm going to disagree slightly on using a QWizard here. It would be fairly easy to do, but in this case I think it might be easier to just use a QStackedWidget and swap the widget shown based on what you want the user to be able to do. This is likely what is done inside QWizard anyway, without some of the complication for running the buttons and moving back and forth. You also might want to take a look at the state machine stuff they're looking at adding soon, since you're application could so easily be split into states.
I think a QWizardPage is your best bet.
You can disable the 'back' on a QWizardPage by using setCommitPage(True) on it.
You'll also have to override nextId for the 'variable' amount of QWizardPages you want in between step 2 and 4.
here (basic) and here are examples of QWizards.
You can make QWizardPages for your screens and add them to a QWizard. With registerField() you can register fields to communicate between pages.
EDIT:
I didn't test this, but i guess you can control the button layout of QWizard with
setButtonLayout
Create a dialog with a "Start Import" button on top. When the user clicks this:
Populate a QFormLayout :
The layout should have a checkbox and the label is the name of the picture to import. I'm not sure of your requirements, but you could also display a thumbnail of the image.
The user just checks the images he wants.
Then at the bottom have a "Save..." button. When the user clicks this, a Save As dialog appears. You save all the checked images, discard the others.
If there are no images, change the "Save..." button text to "OK", and display a QLabel with the "No images left" string. You can switch between the QLabel and QFormLayout using a QStackedWidget.
Checkout this article on QFormLayout: http://doc.trolltech.com/qq/qq25-formlayout.html
Option: Get rid of the "Start Import" button. Have the app automatically populate the QFormLayout on startup (possibly in constructor if its fast enough).