Hi,
I am looking for example code that consists of just a frame and a
grid(10x2). The grid must fill the its parent even if the frame is
resized.
Thanks in advance,
Roger 6 2738
In article <11**********************@u72g2000cwu.googlegroups .com>,
<rb*****@hotmail.com> wrote: Hi,
I am looking for example code that consists of just a frame and a grid(10x2). The grid must fill the its parent even if the frame is resized.
This simple program makes a two element window, the lower half of
which is a gridded set of labels which resize with the window. The
important part is the columnconfigure() and rowconfigure() method
calls on the container widget for the grid.
See
<URL:http://infohost.nmt.edu/tcc/help/pubs/tkinter/grid-config.html> http://infohost.nmt.edu/tcc/help/pub...id-config.html
#!/usr/local/bin/python
from Tkinter import *
root = Tk()
# create a frame (unused, but shared with gridded frame)
f = Frame(height = 100)
f.pack(expand = YES, fill = BOTH)
# create a frame for a gridded display
gf = Frame()
gf.pack(expand = YES, fill = BOTH)
# create a 3 x 4 array of labels, each with a different background
# Make each row and column have equal weights, so they'll
# grow and shrink together
for row in range(3):
gf.rowconfigure(row, weight = 1)
for col in range(4):
gf.columnconfigure(col, weight = 1)
Label(gf, text = "Row: %d\nCol: %d" % (row, col),
bg = "#%02x%02x%02x" % ((row * 4 + col) * 16,
(row * 4 + col) * 16,
(row * 4 + col) * 16),
fg = "#ffffff"
).grid(row = row, column = col, sticky = NSEW)
root.mainloop()
--
Jim Segrave (je*@jes-2.demon.nl) rb*****@hotmail.com wrote: I am looking for example code that consists of just a frame and a grid(10x2). The grid must fill the its parent even if the frame is resized.
Have you gone through the wxPython demo application? It contains examples
of every standard control and almost every behavior you might want.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Tim Roberts wrote: rb*****@hotmail.com wrote: I am looking for example code that consists of just a frame and a grid(10x2). The grid must fill the its parent even if the frame is resized.
Have you gone through the wxPython demo application? It contains examples of every standard control and almost every behavior you might want. -- - Tim Roberts, ti**@probo.com Providenza & Boekelheide, Inc.
Yes, and i have even checked out "wxpython in action". All of the
examples tend to leave white space on the right of the frame. I tried
basic a example with sizers and it didnt work. That why I was
wondering if someone had got it to work.
Roger rb*****@hotmail.com a écrit : Tim Roberts wrote: rb*****@hotmail.com wrote: I am looking for example code that consists of just a frame and a grid(10x2). The grid must fill the its parent even if the frame is resized. Have you gone through the wxPython demo application? It contains examples of every standard control and almost every behavior you might want. -- - Tim Roberts, ti**@probo.com Providenza & Boekelheide, Inc.
Yes, and i have even checked out "wxpython in action". All of the examples tend to leave white space on the right of the frame. I tried basic a example with sizers and it didnt work. That why I was wondering if someone had got it to work.
Roger
Hi Roger,
A key point is that the Grid manages itself its available space
according to the size it can have.
If you just tried to create a simple grid within a simple frame, you
probably got a grid filling all the frame space, and it's what you want.
Why that ?
If you do it (for instance with the script below), and you try to
manually reduce/increase the size of the window, you should see
scrollbars at the edge of the window ; these scrollbars come from the
grid, because they take in account the labels row and col (wxGrid comes
from wxScrolledWindow). You can see that no more space is available
beyond the scrollbar, so the grid takes the whole space.
And why the white space on the right ? This space is not on the right of
the grid, but on the right of the last col. We could think it's like
that because it's not possible to compute an appropriate col size for
the grid cols, but it's not displayed exactly the same in linux and in
windows. In one case it's over the last col (not enough space) and in
the other case it's beyond (too much space). I think that as the program
must work on all the environments, the interface must stay enough
global, and sometimes the display is not perfectly done.
The advantage is that if we let wx decide, we won't have to think how to
set the widgets.
Regards,
jm
#----------------------------------------------------------------------
import wx,wx.grid
#----------------------------------------------------------------------
class MainWindow(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,wx.ID_ANY,title)
#--
self.grid= wx.grid.Grid(id=wx.ID_ANY,parent=self)
self.grid.CreateGrid(numRows=10,numCols=2)
self.grid.Fit()
self.Fit()
#--
self.Show(1)
#----------------------------------------------------------------------
app = wx.PySimpleApp()
frame=MainWindow(None,-1,'Grid sizer')
app.MainLoop()
del app
#----------------------------------------------------------------------
jean-michel bain-cornu wrote: rb*****@hotmail.com a écrit : Tim Roberts wrote: rb*****@hotmail.com wrote: I am looking for example code that consists of just a frame and a grid(10x2). The grid must fill the its parent even if the frame is resized. Have you gone through the wxPython demo application? It contains examples of every standard control and almost every behavior you might want. -- - Tim Roberts, ti**@probo.com Providenza & Boekelheide, Inc.
Yes, and i have even checked out "wxpython in action". All of the examples tend to leave white space on the right of the frame. I tried basic a example with sizers and it didnt work. That why I was wondering if someone had got it to work.
Roger Hi Roger, A key point is that the Grid manages itself its available space according to the size it can have. If you just tried to create a simple grid within a simple frame, you probably got a grid filling all the frame space, and it's what you want. Why that ? If you do it (for instance with the script below), and you try to manually reduce/increase the size of the window, you should see scrollbars at the edge of the window ; these scrollbars come from the grid, because they take in account the labels row and col (wxGrid comes from wxScrolledWindow). You can see that no more space is available beyond the scrollbar, so the grid takes the whole space. And why the white space on the right ? This space is not on the right of the grid, but on the right of the last col. We could think it's like that because it's not possible to compute an appropriate col size for the grid cols, but it's not displayed exactly the same in linux and in windows. In one case it's over the last col (not enough space) and in the other case it's beyond (too much space). I think that as the program must work on all the environments, the interface must stay enough global, and sometimes the display is not perfectly done. The advantage is that if we let wx decide, we won't have to think how to set the widgets. Regards, jm
#---------------------------------------------------------------------- import wx,wx.grid #---------------------------------------------------------------------- class MainWindow(wx.Frame): def __init__(self,parent,id,title): wx.Frame.__init__(self,parent,wx.ID_ANY,title) #-- self.grid= wx.grid.Grid(id=wx.ID_ANY,parent=self) self.grid.CreateGrid(numRows=10,numCols=2) self.grid.Fit() self.Fit() #-- self.Show(1) #---------------------------------------------------------------------- app = wx.PySimpleApp() frame=MainWindow(None,-1,'Grid sizer') app.MainLoop() del app #----------------------------------------------------------------------
Thanks Tim,
I knew it was something like that, but I had to ask the question. I
was hoping that there was a way around the problem.
Roger
jean-michel bain-cornu wrote: rb*****@hotmail.com a écrit : Tim Roberts wrote: rb*****@hotmail.com wrote: I am looking for example code that consists of just a frame and a grid(10x2). The grid must fill the its parent even if the frame is resized. Have you gone through the wxPython demo application? It contains examples of every standard control and almost every behavior you might want. -- - Tim Roberts, ti**@probo.com Providenza & Boekelheide, Inc.
Yes, and i have even checked out "wxpython in action". All of the examples tend to leave white space on the right of the frame. I tried basic a example with sizers and it didnt work. That why I was wondering if someone had got it to work.
Roger Hi Roger, A key point is that the Grid manages itself its available space according to the size it can have. If you just tried to create a simple grid within a simple frame, you probably got a grid filling all the frame space, and it's what you want. Why that ? If you do it (for instance with the script below), and you try to manually reduce/increase the size of the window, you should see scrollbars at the edge of the window ; these scrollbars come from the grid, because they take in account the labels row and col (wxGrid comes from wxScrolledWindow). You can see that no more space is available beyond the scrollbar, so the grid takes the whole space. And why the white space on the right ? This space is not on the right of the grid, but on the right of the last col. We could think it's like that because it's not possible to compute an appropriate col size for the grid cols, but it's not displayed exactly the same in linux and in windows. In one case it's over the last col (not enough space) and in the other case it's beyond (too much space). I think that as the program must work on all the environments, the interface must stay enough global, and sometimes the display is not perfectly done. The advantage is that if we let wx decide, we won't have to think how to set the widgets. Regards, jm
#---------------------------------------------------------------------- import wx,wx.grid #---------------------------------------------------------------------- class MainWindow(wx.Frame): def __init__(self,parent,id,title): wx.Frame.__init__(self,parent,wx.ID_ANY,title) #-- self.grid= wx.grid.Grid(id=wx.ID_ANY,parent=self) self.grid.CreateGrid(numRows=10,numCols=2) self.grid.Fit() self.Fit() #-- self.Show(1) #---------------------------------------------------------------------- app = wx.PySimpleApp() frame=MainWindow(None,-1,'Grid sizer') app.MainLoop() del app #----------------------------------------------------------------------
Thanks Tim,
I knew it was something like that, but I had to ask the question. I
was hoping that there was a way around the problem.
Roger This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Daniel Ehrenberg |
last post by:
I'm trying to learn wxPython, but I can't seem to find much
documentation. The wxPython website says that all advanced (and even
some basic) documentation for wxPython is only available in C++...
|
by: Martin Zuber |
last post by:
Hello,
I have found following problem: When I define event handler for
EVT_NOTEBOOK_PAGE_CHANGED for wxNotebook, the content of the wxNotebook
disappears (on all pages). For ex. I have two pages...
|
by: Johnny Geling |
last post by:
I would like use custom labelnames for rows in the wxGrid which I use
through wxpython. The SetRowLabelValue from wxGridTableBase isn't doing
anything.
Is it posible to use custom rowlabels same...
|
by: Andrew |
last post by:
Hi I just started learning wxPython
I wanted to know how I could do this in wxPython
self.listbox.delete(0, END)
for item in self.results:
self.listbox.insert(END, item)
|
by: Piet |
last post by:
Hi there,
I am currently developping a small app for the purpose mentioned
above. The app connects to a MySQL database, can show the properties
of tables (which are displayed as a wxGrid) and...
|
by: matthiasjanes |
last post by:
dear all,
I just need a little help.
could anyone give real code example (simple) how to read the value of
a grid cell.
i could not figure it out and really would like to do a simple...
|
by: Piet |
last post by:
Hello.
I am working on an XML editor that will not display the xml file as
plain text, but will rather work with a combination of a tree view for
the main element nodes and some kind of tabular...
|
by: Sam the Cat |
last post by:
using "from wxPython.wx import *" under python2.3 I cannot seem to find the
wxGrid class -- it says its undefined -- am I missing something obvious ? I
know the globalspace import is not the best,...
|
by: Steven W. Orr |
last post by:
python-2.3.5
wx-2.6
I just bought the wxPython In Action book and I see that all the examples
say to
import wx
All of our pre-existing code was horribly doing a
from wxPython import *
I...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |