tkinter

How to get a horizontal scrollbar in Tkinter?

一曲冷凌霜 提交于 2021-02-19 04:09:24
问题 I'm learning Tkinter at the moment. From my book, I get the following code for producing a simple vertical scrollbar: from tkinter import * # Import tkinter class ScrollText: def __init__(self): window = Tk() # Create a window window.title("Scroll Text Demo") # Set title frame1 = Frame(window) frame1.pack() scrollbar = Scrollbar(frame1) scrollbar.pack(side = RIGHT, fill = Y) text = Text(frame1, width = 40, height = 10, wrap = WORD, yscrollcommand = scrollbar.set) text.pack() scrollbar.config

Why won't the Python Tkinter Canvas Scroll?

一世执手 提交于 2021-02-19 04:09:22
问题 Why can't I get the python tkinter canvas to respond to the vertical and horizontal swiping/scrolling of Apple's Magic Mouse? The scrollbars for the canvas work properly (meaning the horizontal bar works when I swipe/scroll horizontally on the mouse but not when I swipe/scroll vertically, and the vertical scrollbar moves when I swipe/scroll vertically but doesn't react to any horizontal swiping/scrolling motion), but the canvas doesn't react to any swiping/scrolling of the mouse. Here is my

How to get a horizontal scrollbar in Tkinter?

限于喜欢 提交于 2021-02-19 04:08:45
问题 I'm learning Tkinter at the moment. From my book, I get the following code for producing a simple vertical scrollbar: from tkinter import * # Import tkinter class ScrollText: def __init__(self): window = Tk() # Create a window window.title("Scroll Text Demo") # Set title frame1 = Frame(window) frame1.pack() scrollbar = Scrollbar(frame1) scrollbar.pack(side = RIGHT, fill = Y) text = Text(frame1, width = 40, height = 10, wrap = WORD, yscrollcommand = scrollbar.set) text.pack() scrollbar.config

Why won't the Python Tkinter Canvas Scroll?

五迷三道 提交于 2021-02-19 04:05:59
问题 Why can't I get the python tkinter canvas to respond to the vertical and horizontal swiping/scrolling of Apple's Magic Mouse? The scrollbars for the canvas work properly (meaning the horizontal bar works when I swipe/scroll horizontally on the mouse but not when I swipe/scroll vertically, and the vertical scrollbar moves when I swipe/scroll vertically but doesn't react to any horizontal swiping/scrolling motion), but the canvas doesn't react to any swiping/scrolling of the mouse. Here is my

Tkinter - How to create submenus in menubar

我是研究僧i 提交于 2021-02-19 01:56:08
问题 Is it possible? By looking at the options I'm stumped. Searching on the web hasn't lead me anywhere. Can I create a submenu in the menubar. I'm referring to doing something similar to Idle Shell when I click on File and go down to Recent Files and it pulls up a separate file showing the recent files I've opened. If it's not possible what do I have to use to get it to work? 回答1: You do it exactly the way you add a menu to the menubar, with add_cascade . Here's an example: # Try to import

Creating a game board with Tkinter

浪尽此生 提交于 2021-02-18 22:38:45
问题 I am trying to build a simple game of Connect Four with Python(2.7) I have created a board, that consists of a simple multidimensional Python list. My Board list looks like this: board = [ [_,_,_,_,_,_,_,_,_,_], [_,_,_,_,_,_,_,_,_,_], [_,_,_,_,_,_,_,_,_,_], [_,_,_,_,_,_,_,_,_,_], [_,_,_,_,_,_,_,_,_,_], [_,_,_,_,_,_,_,_,_,_], [_,_,_,_,O,_,_,_,_,_], [_,_,_,_,X,_,_,_,_,_], [_,_,_,_,X,O,_,_,_,_], [_,_,_,_,X,O,_,_,_,_], ] Were X is Player1 and O is Player2 (or Computer). Now, I have created some

Why does the “geometry()” method work with a delay?

不羁岁月 提交于 2021-02-18 11:14:12
问题 If i run this Python code: from Tkinter import *; w = Tk(); w.geometry( "640x480" ); print( w.geometry() ) i will get "1x1+0+0" output. But if i start interpreter and execute this as two separate commands, i will get completely different output: >>> from Tkinter import *; w = Tk(); w.geometry( "640x480" ) '' >>> w.geometry() '640x480+101+73' It seems geometry is not applied instantly, something else is needed : (. Maybe anyone knows what i need to do in order to update geometry inplace? I

Why does the “geometry()” method work with a delay?

元气小坏坏 提交于 2021-02-18 11:13:06
问题 If i run this Python code: from Tkinter import *; w = Tk(); w.geometry( "640x480" ); print( w.geometry() ) i will get "1x1+0+0" output. But if i start interpreter and execute this as two separate commands, i will get completely different output: >>> from Tkinter import *; w = Tk(); w.geometry( "640x480" ) '' >>> w.geometry() '640x480+101+73' It seems geometry is not applied instantly, something else is needed : (. Maybe anyone knows what i need to do in order to update geometry inplace? I

Make tkinter buttons for every item in a list?

隐身守侯 提交于 2021-02-18 07:56:26
问题 I would like to make some buttons, with a list of items I get back from a database, that all call a function passing in the list item. Something like this code but that works. The problem with this code is that all of the buttons call the function with 'item3' . #!/usr/bin/env python from Tkinter import * root = Tk() def func(name): print name mylist = ['item1','item2','item3'] for item in mylist: button = Button(root,text=item,command=lambda:func(item)) button.pack() root.mainloop() 回答1:

Is it possible to apply gradient colours to BG of Tkinter python widgets

五迷三道 提交于 2021-02-18 06:41:10
问题 I am just trying to add background colors as gradient colors! This may look my Tkinter-GUI more attractive than common color codes. Is there any way to achieve this in python, can anyone please help me Can it incorporate something like this? bg="40%,#207cca 40%,#2989d8 50%" def createwidgets(self): master_f = Tkinter.Frame (objMG.root, relief='sunken', bd=2,height =10,bg='#54596d') master_f.pack (side='top', fill='both', expand=1) self.Up_frame = Tkinter.Frame(master_f,relief='sunken',height