grid-layout

Tkinter.grid spacing options?

偶尔善良 提交于 2019-12-01 18:44:31
问题 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' so that I can place, for example, a label in cell (3,8) or a button in cell (5,1). Here is an example of what I've tried: import tkinter as tk root = tk.Tk() label = tk.Label(root, text = 'Label') label.grid(column = 3, row = 8) button = tk.Button(root, text = 'Button') button.grid(column = 5,

How to use MouseListener to find a specific cell in a grid

那年仲夏 提交于 2019-12-01 18:09:16
I'm trying to create a Java game with a 10 x 10 grid made up of cells. The Grid looks liks this: public class Grid extends JPanel implements MouseListener { public static final int GRID_SIZE = 10; public Grid() { setPreferredSize(new Dimension(300, 300)); setLayout(new GridLayout(GRID_SIZE, GRID_SIZE)); for (int x = 0; x < GRID_SIZE; x++) for (int y = 0; y < GRID_SIZE; y++) add(new Cell(x, y)); addMouseListener(this); } // All Mouse Listener methods are in here. The Cell class looks like this: public class Cell extends JPanel { public static final int CELL_SIZE = 1; private int xPos; private

Wrap CSS grid with auto placement

三世轮回 提交于 2019-12-01 16:37:26
问题 I'm trying to build a grid that contains card-like items. The cells of each type (headline, image, text, button, ...) should have equal height in each row, determined by the content of the largest cell, as in the code snippet below. Now I'm trying to limit the number of columns, and let the cards wrap, as if I used flex-wrap: wrap; in a flexbox-based solution. The number of columns should be determined via media query. Is this possible without using the not-yet-supported subgrids?

How to create a CSS Grid Layout box that spans 2 columns and 2 rows?

半城伤御伤魂 提交于 2019-12-01 09:07:11
I've created a grid layout following the newest CSS Grid spec, but am not completely familiar with it yet. I'm trying to create the following layout without having to define grid areas for each grid child. codepen body { max-width: 1024px; margin: 10px auto; } .grid { display: grid; grid-gap: 10px; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; grid-template-areas: "a a b" "a a c" "d e f"; } .grid__thing { background-color: rebeccapurple; } .a { grid-area: a; } .b { grid-area: b; } .c { grid-area: c; } .d { grid-area: d; } .e { grid-area: e; } .f { grid-area: f; } img {

CSS - Responsive grid with equal margins and fixed size blocks

独自空忆成欢 提交于 2019-12-01 07:20:25
I'm trying to push the limits of CSS to replicate what would be a common grid-layout in print. Requirements : Margins between blocks and between blocks and edge of the container must be equal. The layout must be responsive and the number of blocks on each row must adapt to the size of the window. The last row must be left aligned the width/height of the blocks is fixed no use of empty non-semantic HTML elements pure CSS solution, no JS So, I have markup that looks like this: <ul> <li> <img src="thumbnail.jpg"> <span>Introduction and Curriculum</span> </li> <li> <img src="thumbnail.jpg"> <span

How to create a CSS Grid Layout box that spans 2 columns and 2 rows?

允我心安 提交于 2019-12-01 07:10:32
问题 I've created a grid layout following the newest CSS Grid spec, but am not completely familiar with it yet. I'm trying to create the following layout without having to define grid areas for each grid child. codepen body { max-width: 1024px; margin: 10px auto; } .grid { display: grid; grid-gap: 10px; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; grid-template-areas: "a a b" "a a c" "d e f"; } .grid__thing { background-color: rebeccapurple; } .a { grid-area: a; } .b { grid

CSS - Responsive grid with equal margins and fixed size blocks

余生颓废 提交于 2019-12-01 05:15:24
问题 I'm trying to push the limits of CSS to replicate what would be a common grid-layout in print. Requirements : Margins between blocks and between blocks and edge of the container must be equal. The layout must be responsive and the number of blocks on each row must adapt to the size of the window. The last row must be left aligned the width/height of the blocks is fixed no use of empty non-semantic HTML elements pure CSS solution, no JS So, I have markup that looks like this: <ul> <li> <img

How to align separate Grids created via templates along their columns / rows?

天大地大妈咪最大 提交于 2019-12-01 03:31:59
I thinks that in this case A picture is worth a thousand words: XAML: <Grid> <ItemsControl ItemsSource="{Binding Persons}"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition/> </Grid.ColumnDefinitions> <TextBlock Text="{Binding Name}" Background="LightBlue"/> <TextBlock Text="{Binding Age}" Background="LightPink" Grid.Column="1"/> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </Grid> p.s - I don't want to set a specific with to the first column, but to give it the max with that it needs. Update:

How is “grid-template-rows: auto auto 1fr auto” interpreted?

余生长醉 提交于 2019-12-01 01:22:50
问题 Recently, I created a layout using CSS grid. While this works well, I'm confused by how it works. Specifically, I'm confused about the line grid-template-rows: auto auto 1fr auto; . What ended up happening here is that the header and footer sized according to the content, which makes sense since they spanned the width of the page. The article itself sized according to its content. But, the "title" and "nav" were split such that the title sized according to content and nav took the rest of the

How does one fill a QGridLayout from top-left to right?

百般思念 提交于 2019-11-30 21:02:19
I would like to fill a QGridLayout with QWidgets . The QWidgets need to appear in a top-left to top-right fashion and proceed to fill the down downwards after each row is filled with QWidgets . An example of a similar and familiar GUI is how Apple sorts its apps on the iPhone or iPad's home screen. The apps go top-left to top-right and proceed to go downward after each row is filled. Right now, whenever I add elements, they take up the entirety of the screen and/or aren't added next to each other. This is example code of what I am doing m_gridLayout = new QGridLayout(this); this->setLayout(m