I have the following code and I would like to know how to set the
length and width of widgets like Buttons. When the window opens the
button fills up the space even though I have told it not to. Anyone
know how I can accomplish this?
:
import pygtk, gtk
class Greeter:
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.box = gtk.VBox()
self.window.add(self.box)
self.label = gtk.Label("Please enter your name in the box below:")
self.namebox = gtk.Entry(12)
self.button = gtk.Button("Greet Me!")
self.output = gtk.Label("Your output will appear here.")
self.box.pack_start(self.label, False, False, 2)
self.box.pack_start(self.namebox, False, False, 2)
self.box.pack_start(self.button, False, False, 2)
self.box.pack_start(self.output, False, False, 2)
self.label.show()
self.namebox.show()
self.button.show()
self.output.show()
self.box.show()
self.window.show()
def main(self):
gtk.main()
a = Greeter()
a.main() 1 2129
Harlin Seritt wrote: I have the following code and I would like to know how to set the length and width of widgets like Buttons. When the window opens the button fills up the space even though I have told it not to.
Your button is stretched horizontally because there is nothing to put
around it in order to fill the space. Try to embed it into a HBox,
surrounded by empty labels :
import pygtk, gtk
class Greeter: def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.box = gtk.VBox() self.window.add(self.box) self.label = gtk.Label("Please enter your name in the box below:") self.namebox = gtk.Entry(12) self.button = gtk.Button("Greet Me!") self.output = gtk.Label("Your output will appear here.")
hbox = gtk.HBox() self.box.pack_start(self.label, False, False, 2) self.box.pack_start(self.namebox, False, False, 2)
hbox.add(gtk.Label())
hbox.pack_start(self.button, False, False, 2)
hbox.add(gtk.Label())
self.box.pack_start(hbox, False, False, 2) self.box.pack_start(self.output, False, False, 2)
self.window.show_all() def main(self): gtk.main()
a = Greeter() a.main()
Cheers,
Franck This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rick Muller |
last post by:
I have a problem that I would like to get some advice on from other
Pythonistas. I currently manage a (soon to be) open source project for
displaying molecular graphics for a variety of different...
|
by: Harlin Seritt |
last post by:
There are certain options for Tkinter widgets that have default values
that I don't much care for (borderwidth, font come to mind) and
continuously change when I'm building interfaces. With a bit...
|
by: TPJ |
last post by:
GUI's etc: PyGtk on Windows
"(...) So if someone develops mainly for X and just wants to make sure
that it is not impossible to run on Windows, you can use PyGTK. (...)",
July 2nd, 1999
pyGTK...
|
by: jubei |
last post by:
I've been trying to write a custom widget for a project, however when i try to run code that uses it i get the following error
> ./nokiagui.py
Traceback (most recent call last):
File...
|
by: krishnakant Mane |
last post by:
hello,
I will be writing some code in PyGTK to run on linux. but I want to
know if there are any installers or distutils available for PyGTK on
windows?
I have heard that installing gimp or even...
|
by: stevemcc |
last post by:
I am trying to make a game using pygtk. It requires that there be an image in the background and widgets that can go in front of the image. I have tried defining a background image for the Mainwindow...
|
by: Whiplash |
last post by:
I want to build some basic kid games for Linux (Ubuntu/EdUbuntu) and
so after looking around I've decided that Python would probably be the
path of least resistance.
I have a need to create...
|
by: Steve |
last post by:
I have a div with two - three paragrahs in it. Each paragraph has
its own inline style tag with its own font size setting. When I set
the last paragraph's font size the font sizes for ALL of...
|
by: Michael Palmer |
last post by:
On Sep 16, 12:30 pm, binaryjesus <coolman.gu...@gmail.comwrote:
I haven't tried it myself, but I came across a blog post the other day
that describes a way of building windows installers for...
|
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: 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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |