Python Tkinter: multiple images and text on a BIG button? - python

Is it possible to mount more than one image AND text on a Tkinter button?
Or, is it possible to put a FRAME containing images + text on a button?
I want a big button containing multiple widgets that, when taken together, fully describe the option the user will be able to choose.
I appreciate any suggestions!!

Is it possible to mount more than one image AND text on a Tkinter button?
Strictly speaking, no, it is not possible.
Or, is it possible to put a FRAME containing images + text on a button?
Yes, though it probably won't work on OSX. It would probably take you less time to actually try it than to type in the question on stackoverflow. A little research goes a long way.
You can also simply not use a button. Just use a frame or canvas, and set up bindings on the container and/or it's contents to react to a button click.

Related

Trying to find way to automate clicking button process on a company application with out images

I have a script that is used to login in to a company-made application and click the right buttons like "continue", or "ok", etc. to perform a certain process. However, I have had to use screenshots of these buttons to click in order to do this using pyautogui. Is there any package or way to automate this process without using images. Maybe it can detect the text of the button and click it. I do not have identifiers for the buttons available and no access to the code/info behind the application. Let me know if you have any ideas. Thanks!
I have a few questions that may be helpful:
Does the layout of the buttons change? If it's always the same you can just program the correct locations and timing and not worry about reading the screen.
If you really have to read the screen, look into optical character recognition (ocr).
Is the application keyboard accessible? If so, using Tab and Enter to activate the buttons is simpler than controlling the mouse. Also, if it was made by superstars you can use find (ctrl-F) to search for the text on the buttons and go to them.
This answer is pretty vague, but I can only be as specific as the question asked.

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

Modifying a Part of Text on tk.Button

I wonder if it is possible to change the weight of one word on a tkinter button? So the result would look something like this:
[ yes, I agree ]
I've tried using tags but neither tk.Button nor tk.Button['text'] seem to allow it.
Thanks!
No, it's not possible. If you want a button with rich text you'll have to create your own. Or, create an image that has the look you want, and use the image with a standard button.
You can create your own using a text widget that is one character tall and a few characters wide. Then, you can place bindings on the button to handle clicks, and to change the relief to simulate a button. Unfortunately, it won't have the look of the platform-specific buttons.

Python tkinter: a scrollable list with text and images?

I'm using python 2.7 and I'd like to have an GUI with a scrollable list where each item in the list has both an image and some text. I'd like these items to be selectable like in a ListBox. I've tried a couple things and it seems ListBox only accepts text?
What widget/combination of widgets should I use?
Try placing a whole bunch of buttons in a frame and assigning a scroll bar a to that frame and make it so when the user presses a button is changes colour or picture or something and then any button with that same colour of picture before will go back to normal. Also, and a tkinter variable with which button is active so you can reference it later.
I'm fairly sure you can use both texts and images in a button simultaneously, but if not you can just put a button and an image side by side in the same row on the frame
I recommend you make this entire scrolling object a class and keep references of everything inside within that class.
If you need any help doing this, just give me a shout.

How to send the text pasted in a textbox of a html webpage to the application written in python in the harddisk?

I have a application running in python, i want to send the input taken from the text box of the webpage and send it as input to the application and once again the output of the application which is in text format back to the result page on web.
thanks a lot for your time :) :)
Here's my suggestion: modify your program to include a button for doing the transformation. When you click it, it should take the contents of the clipboard, do whatever transformation you want, and put the result back on the clipboard.
Once you do that, to use it you select the text from the widget, use the keyboard to copy it to the clipboard, press the button on the GUI, then click back in the widget and use the keyboard to paste.
Alternately, your program can just poll the clipboard every couple of seconds, do the transformation and put the results back (make sure your automatic polling ignores any changes caused by itself). With that you can do a select-all, copy, wait a couple seconds, then paste.
This is pretty trivial to do in both Tkinter and wxPython, and I would guess it is equally trivial with most other GUI toolkits.
Have you tried PyQt4 which has this ability built-in? You can do what you're asking in about ten LOC.

Categories

Resources