All Questions

Tagged with
Filter by
Sorted by
Tagged with
25 votes
4 answers
101k views

How to horizontally center a widget using grid()?

I am using grid() to place widgets in a tkinter window. I am trying to put a label on the horizontal center of a window and have it stay there, even if the window is resized. How could I go about ...
L4undry's user avatar
  • 289
15 votes
1 answer
48k views

Tkinter grid fill empty space

I did search for a lot of examples before posting but still can't properly use the tkinter grid. What I want: my code: import tkinter as tk from tkinter import ttk root = tk.Tk() b1 = ttk.Button(...
Vítor Nunes's user avatar
12 votes
2 answers
59k views

Tkinter.grid spacing options?

I'm new to Tkinter, and I tried creating an app with the grid layout manager. However, I can't seem to find a way to utilize it the way I want to. What I need to do is simulate a grid full of 'cells' ...
PlatypusVenom's user avatar
8 votes
1 answer
11k views

PyQT5: Grid layout inside horizontal layout

Can someone help me figure out how to combine layouts? Taking offset from the guides from: [https://pythonspot.com/en/pyqt5/] I would rather not use Designer as the layout is going to be a part of ...
Max Møller Madsen's user avatar
7 votes
3 answers
12k views

Tkinter Grid Dynamic Layout

I am wanting to create a grid layout, with a grid that fills the first row until it runs out of space in the window, and will dynamically move items to the row below (like text line-wrapping). As the ...
Tarm's user avatar
  • 193
4 votes
3 answers
2k views

Printing a dict of lists as a grid-layout

Ok, I read all of these before and I think pandas could be a solution, but my problem is slighly different: Print a dictionary of lists vertically Printing Lists as Tabular Data print dictionary ...
Ando Jurai's user avatar
  • 1,033
3 votes
1 answer
3k views

Python: Getting started with tk, widget not resizing on grid?

I'm just getting started with Python's Tkinter/ttk and I'm having issues getting my widgets to resize when I use a grid layout. Here's a subset of my code which exhibits the same issue as the full ...
ArtOfWarfare's user avatar
3 votes
1 answer
3k views

Gtk.Grid(): how to dynamically modify the number of rows

How can I change the simple_table_code from below, to have the possibility of modifying the number of rows of a Gtk.Grid (for example by clicking one of the buttons)? I suppose I must remove grid ...
mpruchni's user avatar
  • 300
2 votes
1 answer
2k views

How to align label and text input in one row with kivy?

I'm struggling to understand layout positioning in Kivy. My aim is to create a simple form containing 3 rows, each one consisting of a label and a text input. For example, like on this wireframe drawn ...
AnjaM's user avatar
  • 2,981
2 votes
1 answer
8k views

Setting grid column width in Kivy's GridLayout?

I'm currently creating a very simple GUI app which needs a few button on the left (in a narrow pane) and a matplotlib chart on the right (the wider one). I'm not experienced with Python GUIs but I ...
Straightfw's user avatar
  • 2,153
2 votes
1 answer
1k views

pygame - Snap Mouse to Grid

I'm making a little platformer game using pygame, and decided that making a level editor for each level would be easier than typing each blocks' coordinate and size. I'm using a set of lines, ...
Uzair Ahmed's user avatar
2 votes
1 answer
2k views

Why is TKinter OptionMenu changing the size of it's parent?

I have this GUI program, and one of the Frames has an OptionMenu in it. Whenever I select something in the OptionMenu, it resizes the parent frame, even though it has more than enough room to fit in ...
Matthew Fournier's user avatar
2 votes
1 answer
512 views

Adding label to tkinter widget changes entire layout

I am making a python text editor, and I am now busy with the find function. Then when the last occurance of the users input is found, it jumps back to the beginning again, and it shows the text 'Found ...
Conner Dassen's user avatar
2 votes
1 answer
374 views

Kivy: assigning actions/classifying buttons in grid

I'm having an issue with assigning actions to the buttons I've put in a grid in kivy. Any help would be appreciated. I am new to all things coding but I have been trying to work this out. I tried to ...
grimtrigger's user avatar
2 votes
0 answers
99 views

add an image to GridLayout in a .kv file from python

How can I add an image object to a GridLayout defined in a .kv file? Is this possible? I have tried ui.py class Field(Widget): grid = ObjectProperty() grid.add_widget(Image(source=&...
Colin Sutter's user avatar
2 votes
0 answers
134 views

Aligning entries in nested grid layouts in tkinter

I have the following code: from tkinter import * class GUI(Tk): def __init__(self, *args, **kw): super().__init__(*args, **kw) self.frame = Frame(self) self.frame.pack(fill=BOTH, ...
Mate de Vita's user avatar
  • 1,175
1 vote
1 answer
3k views

Change the position of widget within a grid?

What I need to know is if there is a way to put a widget into a different grid cell after already gridding it. The reason I need to do this is because I am making a tkinter program in python with ...
PlatypusVenom's user avatar
1 vote
1 answer
2k views

How to stretch cell horizontally using grid in Tkinter?

I was using tkinter to make simple GUI and I wanted to make it too simple and cool so I wanted to this label ********** to be filled in screen but the there is no option for fill in grid like in pack ...
user avatar
1 vote
2 answers
8k views

How to set a height to some buttons of GridLayout in Kivy Python?

I'm working in an app with kivy and I have an issue that involve the GridLayout. I have a screen with different rows and I want the buttons of the last row to have always the same height (11,1% of the ...
A.Piquer's user avatar
  • 424
1 vote
2 answers
42 views

Can I define a value in a dictionary directly using a for loop within the dictionary itself?

I'm working in some Project Euler problems and have a solution I'd like to make more adaptable. The problem itself isn't important here but for those of you that are curious, it's problem 11. ...
Maxime Michel's user avatar
1 vote
1 answer
2k views

Tkinter treeview widgets not properly aligned/added space between widgets

I am working on this table in tkinter made from a bunch of treeveiw widgets. The idea is to get a table where I can add lines, select lines and edit them. In the code below you can add lines to the ...
Tola's user avatar
  • 264
1 vote
1 answer
7k views

Python grid columnspan

I want to fill the hole column with a text widgets using grid columnspan.Is that possible? import tkinter root = tkinter.Tk() text = tkinter.Text(root) text.insert('end','Text') text.grid(row=0,...
Strnik's user avatar
  • 37
1 vote
2 answers
143 views

Tkinter: maintaining button distance when resizing window

I am switching the layout manager for my tkinter GUI. I was using place instead of grid because it was easier for me in the first place, altough I knew it would not be very compatible. Now I noticed ...
Maze2Go's user avatar
  • 15
1 vote
1 answer
59 views

Odd interaction between grid_propagate and columnspan

Assigning a columnspan (other than 1) to a child object appears to negate the effects of uniform=1 and grid_propagate(False). Here is a simple example of what I mean (click the text to toggle back and ...
Nathan's user avatar
  • 118
1 vote
1 answer
547 views

Kivy add widget won't appear on screen:

I'm stuck with the following problem: When I run the following code - this seems to work: class Board(GridLayout): def __init__(self, numLines=8, numCols=8, **kwargs): # constructor of the ...
urie's user avatar
  • 361
1 vote
1 answer
588 views

How to create a Dynamic Scrollable Grid on tkinter

When I say a dynamic grid I'm saying a grid that adjusts the number of columns(like bootstrap) according to the window width, so it must adjust the "cards" accordingly, and when I say ...
fils capo's user avatar
  • 306
1 vote
1 answer
297 views

How can i add Grid Layout to my pyqt5 code

I want to add grid layout to my five frames code , it has only one class and the frames should be 3 in the top and 2 in the bottom here is the code.... lass MainProg(QtWidgets.QMainWindow): #def ...
Kikomi's user avatar
  • 49
1 vote
1 answer
29 views

Python when i click button twice qgridlayoutwidget gets weird

**-SOLVED-** Hello I recently made a program which gets imdb api (non-official one) and generate bbcode You can see my code here: pastebin def _search(self): if self.inputBox.text() != '': ...
PatrickKR's user avatar
1 vote
1 answer
2k views

How to grid a ttk Notebook containing two ttk Treeviews so it expands to fill its designated grid cell?

I'm having trouble laying out two same ttk.Treeview widgets using ttk.Notebook and grid layout manager. When I'm working with only one treeview (placed in a labelframe, that is placed in a frame (...
z33k's user avatar
  • 3,446
1 vote
1 answer
390 views

Python - Widget alignment when using multiple frames

I'm facing some trouble aligning tkinter widgets when located in different frames, as shown I have 3 frames: main_frame - colored in blue, containing 3 subframes: buttons_frame,timers_frame,...
guyd's user avatar
  • 713
1 vote
1 answer
3k views

How can I evenly divide space between two frames using the grid geometry manager in tkinter?

I have a tkinter application I'm trying to create. I've deiced to use the grid geometry manger instead of pack. It has been working well so far, but I've come across a strange problem. The basic ...
Christian Dean's user avatar
1 vote
2 answers
652 views

kivy gridlayout, stop dynamic resizing of children

I have a grid layout containing a variable amount of children. n1...n∞, I can never predict how many children the grid will contain. Kivy, rather annoyingly makes the children smaller and smaller in ...
Josh Bloom's user avatar
1 vote
1 answer
2k views

Kivy grid layout fixed column width for some columns

I'd like to construct a grid layout where some columns have a fixed width (to contain an image) while others should take the available space. This is my current situation (last column): As you can ...
Michael Helwig's user avatar
1 vote
1 answer
2k views

xlsxwriter chart grid spacing

I'm currently trying to create charts in excel via the xlsxwriter python module. I've gotten it to graph just fine, however I'm trying to get it to look nice. I've been able to add major and minor ...
TylerH's user avatar
  • 132
1 vote
2 answers
3k views

Tkinter: right align Labels within stretched LabelFrames using grid

Using grid in tkinter, I'm trying to align a set of frames (I would love to post a picture, but I'm not allowed.) I've two outer LabelFrames of different sizes and on top of each other which I'd like ...
Andrea's user avatar
  • 345
1 vote
1 answer
3k views

Image in gridlayout kivy

I am trying to create a 10x10 grid of images in kivy but I find that all the images are separated by a large black border.It appears that the images remain at a constant 0f 100x100 pixels. The code I ...
user2592835's user avatar
  • 1,567
1 vote
1 answer
129 views

separate random numbers in tkinter [closed]

This code showed me some random numbers on the right side on my screen. from Tkinter import * import math from random import randrange number=Tk() number.geometry("1308x720") number.config(bg="black"...
rpi-uts's user avatar
  • 51
1 vote
1 answer
111 views

Creating a matrix over an image

I decided to set the background image as the game board so that I wouldn't have to draw it every frame. The problem I am having now though it trying to create a matrix over this image in which the ...
spam.i.am's user avatar
1 vote
1 answer
2k views

Why does the 'ipady' option in the tkinter.grid() method only add space below a widget?

Below is a code to show the issue. Label1 shows that I need to use pady to displace Label1 by 10 pixels. Label2 shows the default effect of ipady. Why does ipady not leave space above and below the ...
Sun Bear's user avatar
  • 7,918
1 vote
1 answer
854 views

Maya Python: GridLayout - Different width per Cell

So i am trying to figure out how to have a gridlayout in maya, where 2 cells in the same row vary in width. i tried indexing the cells in the cellWidth flag, but with no success. this is what i have ...
dave's user avatar
  • 93
1 vote
2 answers
2k views

Cant figure out how to stop columns and rows from shifting in TkInter GUI

So, I am working on a final project for my Python class and am creating a GUI for a game using TkInter. I have a little 'sprite' if you will that moves across the GUI using button presses. I am trying ...
William's user avatar
  • 11
1 vote
1 answer
1k views

Diagonal lines of squares in grids

I have a python grid class in which I am trying to create a method to get the diagonal line of tiles that a certain tile belongs to. I have succeeded in doing this for going down from left to right in ...
user1149589's user avatar
0 votes
2 answers
708 views

accessing the contents of a kivy GridLayout by coordinates?

Is there a way to access the contents of a kivy GridLayout or BoxLayout by coordinates, like accessing the element of the second row, third column. If not, which I'm afraid is the case, is there ...
user3060854's user avatar
0 votes
2 answers
2k views

How to divide space equally between widgets using Grid Layout Python Tkinter

I want to divide space equally between three buttons using Grid Layout in Tkinter. And those buttons should occupy the space equally even when the window is resized horizontally. ######################...
Carlos Pedro de O. dos S's user avatar
0 votes
2 answers
342 views

Is it possible to animate frames that are layed out with the grid manager in tkinter?

I made this desktop application with tkinter and finished the main functionalities. But now I want to make it look better and even animate the menus is possible. The thing is the buttons and widgets ...
Amrou's user avatar
  • 411
0 votes
1 answer
4k views

How to get a left and right frame to fill in TKinter?

I'm trying to make a window that has two half-window frames on either side, but I can't get them to fill. I need the two frames to take up half of the width and all of the height of the window, no ...
Matthew Fournier's user avatar
0 votes
2 answers
747 views

How to update the widget with updated canvas?

When the button is clicked a plot is generated from 10 random integers. This works fine when the button is first clicked, but after that the graph does not refresh again and no change is observed. How ...
agile's user avatar
  • 77
0 votes
1 answer
23 views

How to get Tkinter Python3.x to nest grids?

I've been trying for days to figure out how to just put grids in grids of objects. I've got two frames (which I guess are widgets in Tk?) I add one to the other, but the position of its widgets don't ...
Krupip's user avatar
  • 4,653
0 votes
2 answers
845 views

Python / How to place symbols in a random place on a 6x6 grid

I'm new to Python and programming and I have a problem with one of the tasks for my programming course. I need to create a game that will be played on a 6 × 6 grid. The grid will represent a map and ...
em.n's user avatar
  • 1
0 votes
2 answers
10k views

How to position labels using the grid method in python tkinter?

Im trying to put a large label at the top of the window in the middle, then 3 Option menus evenly spaced out below it. I can't get the menus to span across the entire window. I'm not sure if what I'm ...
RavenRazor's user avatar