Is there a way to create menu's such as the one provided in WordPad on Windows 7 with Tkinter?
I haven't found anything like it, and it would improve the looks on my scripts immensely.
What you are describing is what Microsoft calls a ribbon. No, there is nothing built-in to tkinter to provide such a menu. Most of the building blocks are there to emulate it (notebooks, buttons, dropdowns, etc), but you'll have to do a fair amount of work to get it to work exactly like a ribbon.
The consensus on ribbons seem to be that they only aid usability when you have a very large amount of controls that you need to present to the user. That is why you see such ribbons on tools like Word and Excel, but not so much on browsers, notepad, etc. I would advise that unless your app needs such a rich toolbar, adding one won't actually improve the usability of your application.
Related
I am fairly new to Python and is stuck at a problem. I am using Python 3.7 and intend to add a "drag-and-drop" functionality to my GUI.
I have some files that needs to be read, thus i am looking for an option where i can simply drag those files to a particular area in my GUI and file name or Path is read by my program.
Being a newbie a detailed answer or a code would be highly helpful.
Thanks
Unfortunately, tkinter only supports experimental widget drag and drop, nothing else. I ran into similar problems trying to make a complex GUI.
I would look into wxPython. It's complex, Object Oriented, and daunting, but has and unbelievable amount of features that reward you for learning it. Including file drag and drop.
Look at the wxPython thumbnails at https://wxpython.org/Phoenix/docs/html/gallery.html for images of what the widgets look like. The thumbnails include images for about half of the available widgets. The images are also a bit out of date.
Look at pronounced https://pythonlibrary.org or https://zetcode.com for the best tutorials. After them, your best resource is Google and the forums.
I have C# experience, and I'm making my first Python app. I'm part way done the UI in QT Designer, and soon I'll try PyQt to integrate it with my code. This is a general guidance question for best approach.
I have a tab widget containing various things in each tab. I would like the entire tab widget to be duplicatable with a plus button. So basically, a scroll view containing as many of these tab widgets as the user wants. The user could duplicate an existing one as a new instance, or create a blank one.
Could someone please help me understand how to accomplish this? Does it work like this?
Create the scroll view.
Put the tab widget inside the scroll view.
Add duplicate and delete buttons in the corner of the tab widget.
Put a plus button just outside the scroll view.
Accomplish all of the rest via python code? Or would I be missing out on some Qt Designer tricks?
Any tips on how to do this in QT Designer and also coding in PyQt would be appreciated.
Additionally, perhaps off topic, but any general tips on PyQt installation and usage would be nice. v5 not v4? I'm running Python 3.6 32 bit, which I was told should run 3.5 packages fine (but 64 bit may not).
Thanks,
First the out of topic : use PyQt5 if you start a new project. Qt 4 has reached end of life and won't see any new release unless it's a critical security fix.
As for most of your questions: if you want to use Designer then you should start by taking a look at Qt Designer's documentation. It will get you started nicely.
As for 5, it depends on tastes. Developers have been using both for various reasons. It's really up to you decide which style fits your needs best. There's no tricks in designer that you can't accomplish in code.
world!
I'd like to ask you one question, a simple solution (I guess) for a nerve-wracking problem I'm encountering using a wx.Lisbook component of wxPython.
In fact, I want to switch from a wx.Panel to another fluently, withou requiring a user input. I've already tried the SetFocus(), Show()/ShowWithEffect() + Hide()/HideWithEffect() methods, without great results.
Show()/Hide() gives the better results, but the selected Thumbnail remains the previous displayed panel...
Any idea of the method or good practice to manipulate wx.Listbook?
Thanks very much by advance for your answers!
Patrice
You want to be able to switch between panels? You should check out the various "Book" controls in wxPython, such as the Toolbook, Notebook, AUINotebook, etc. I also wrote a tutorial that's just on switching panels using the menu:
http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/
You could use a wx.Timer to do the switching too if you didn't want any user involvement.
Beginner python learner here. I have a question that I have tried to Google but I just can't come up with the proper way to ask in just a few words (partly because I don't know the right terminology.)
How do I get python to detect other widgets? For example, if I wanted a script to check and see when I click my mouse if that click put focus on an entry widget on a (for example) website. I've been trying to get it to work in Tkinter and I can't figure out even where to begin.
I've seen this:
focus_displayof(self)
Return the widget which has currently the focus on the
display where this widget is located.
But the return value for that function seems to be some ambiguous long number I can't decipher, plus it only works in its own application.
Any direction would be much appreciated. :)
Do you mean inside your own GUI code, or some other application's/website's?
Sounds like you're looking for a GUI driver, or GUI test/automation driver. There are tons of these, some great, some awful, many abandoned. If you tell us more about what you want that will help narrow down the choices.
Is this for testing, or automation, or are you going to drive the mouse and button yourself and just want something to observe what is going on under the hood in the GUI?
>How do I get Python to detect other widgets?
On a machine, or in a browser? If in a machine, which platform: Linux/Windows (which)/Mac?
If in a browser, which browser (and major version)?
> But the return value for that function seems to be some ambiguous long number I can't decipher
Using longs as resource handles is par for the course, although good GUI drivers also work with string/regex matching on window and button names.
> plus it only works in its own application.
What do you mean, and what are you expecting it to return you? You should be able to look up that GUI object and access its title. Look for a GUI driver that works with window and button names.
Here is one list, read it through and see what sounds useful. I have used AutoIt under Win32, it's great, widely-used and actively-maintained; it can be called from Python (via subprocess).
Here are comparisons by the author of PyWinAuto on his and similar tools. Give a read to his criticisms of its structure from 2010. If none of these is what you want, at least you now have the vocabulary to tell us what would be...
I'd like to write my own GUI text edit for HTML, CSS and PHP. The whole user interface should be as mouse centered as I can get it. If you type "bo" there should be a list with stuff like "body" and "bold", just like you have in every other IDE. Could you point me to some resources on making a fancy editor window?
My choice of programming language is Python, and I'd like to use GTK for the GUI I think.
I'd suggest you to check out Scintilla, a GTK+ component for editing source code. You might find interesting ideas in its code, or use it as a core building block for your project.