wxpython: The GridBagSizer made me confused Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceAdding an AuiToolbar causes “expected argument 3 type int”wxpython GridBagSizer problemwxPython: Nesting GridBagSizers not spanning?Python wxWidgets : Adding components to a Panel fires an wxWindowBase::AddChild(): AddChild() called twice assertion on WindowswxPython: Using a GridBagSizerwxpython Post Erase Background with DCDerived panel classes in wxpythonwxpython - Erase background erases non-background componentswxPython: GridBagSizer: Iterating over rows and columns of a gridbagsizerwxpython GridBagSizer inside ScrolledWindow not working
Complexity of many constant time steps with occasional logarithmic steps
Why is "Captain Marvel" translated as male in Portugal?
Stopping real property loss from eroding embankment
Do working physicists consider Newtonian mechanics to be "falsified"?
How do I keep my slimes from escaping their pens?
What do you call a plan that's an alternative plan in case your initial plan fails?
Biased dice probability question
Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?
How to say that you spent the night with someone, you were only sleeping and nothing else?
How to market an anarchic city as a tourism spot to people living in civilized areas?
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
Slither Like a Snake
How can I make names more distinctive without making them longer?
Classification of bundles, Postnikov towers, obstruction theory, local coefficients
What computer would be fastest for Mathematica Home Edition?
Windows 10: How to Lock (not sleep) laptop on lid close?
Single author papers against my advisor's will?
When is phishing education going too far?
Determine whether f is a function, an injection, a surjection
How should I respond to a player wanting to catch a sword between their hands?
Can a non-EU citizen traveling with me come with me through the EU passport line?
Jazz greats knew nothing of modes. Why are they used to improvise on standards?
Unable to start mainnet node docker container
Did the new image of black hole confirm the general theory of relativity?
wxpython: The GridBagSizer made me confused
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceAdding an AuiToolbar causes “expected argument 3 type int”wxpython GridBagSizer problemwxPython: Nesting GridBagSizers not spanning?Python wxWidgets : Adding components to a Panel fires an wxWindowBase::AddChild(): AddChild() called twice assertion on WindowswxPython: Using a GridBagSizerwxpython Post Erase Background with DCDerived panel classes in wxpythonwxpython - Erase background erases non-background componentswxPython: GridBagSizer: Iterating over rows and columns of a gridbagsizerwxpython GridBagSizer inside ScrolledWindow not working
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am new with python GUI and wxpython
also. Now im facing following problem.
Here the code is
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title)
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self)
sizer = wx.GridBagSizer(0, 0)
text = wx.StaticText(panel, label="Name:")
sizer.Add(text, pos=(0, 0), flag=wx.ALL, border=5)
tc = wx.TextCtrl(panel)
sizer.Add(tc, pos=(0, 1), span=(1, 2), flag=wx.EXPAND | wx.ALL, border=5)
text1 = wx.StaticText(panel, label="address")
sizer.Add(text1, pos=(1, 0), flag=wx.ALL, border=5)
tc1 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc1, pos=(1, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text2 = wx.StaticText(panel, label="age")
sizer.Add(text2, pos=(2, 0), flag=wx.ALL, border=5)
tc2 = wx.TextCtrl(panel)
sizer.Add(tc2, pos=(2, 1), flag=wx.ALL, border=5)
text3 = wx.StaticText(panel, label="Mob.No")
sizer.Add(text3, pos=(2, 2), flag=wx.ALIGN_CENTER | wx.ALL, border=5)
tc3 = wx.TextCtrl(panel)
sizer.Add(tc3, pos=(2, 3), flag=wx.EXPAND | wx.ALL, border=5)
text4 = wx.StaticText(panel, label="Description")
sizer.Add(text4, pos=(3, 0), flag=wx.ALL, border=5)
tc4 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc4, pos=(3, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
sizer.AddGrowableRow(3)
buttonOk = wx.Button(panel, label="Ok")
buttonClose = wx.Button(panel, label="Close")
sizer.Add(buttonOk, pos=(4, 2), flag=wx.ALL, border=5)
sizer.Add(buttonClose, pos=(4, 3), flag=wx.ALL, border=5)
panel.SetSizerAndFit(sizer)
app = wx.App()
Example(None, title='GridBag Demo')
app.MainLoop()
Here the result is
What make me confused is the label address2
.It does not span three columns obviously.
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
But the code of address2
label is same with address
label except param pos
.Can someone explain this.
env: python3.7/wxpython4.0.4(newest)
python wxpython
add a comment |
I am new with python GUI and wxpython
also. Now im facing following problem.
Here the code is
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title)
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self)
sizer = wx.GridBagSizer(0, 0)
text = wx.StaticText(panel, label="Name:")
sizer.Add(text, pos=(0, 0), flag=wx.ALL, border=5)
tc = wx.TextCtrl(panel)
sizer.Add(tc, pos=(0, 1), span=(1, 2), flag=wx.EXPAND | wx.ALL, border=5)
text1 = wx.StaticText(panel, label="address")
sizer.Add(text1, pos=(1, 0), flag=wx.ALL, border=5)
tc1 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc1, pos=(1, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text2 = wx.StaticText(panel, label="age")
sizer.Add(text2, pos=(2, 0), flag=wx.ALL, border=5)
tc2 = wx.TextCtrl(panel)
sizer.Add(tc2, pos=(2, 1), flag=wx.ALL, border=5)
text3 = wx.StaticText(panel, label="Mob.No")
sizer.Add(text3, pos=(2, 2), flag=wx.ALIGN_CENTER | wx.ALL, border=5)
tc3 = wx.TextCtrl(panel)
sizer.Add(tc3, pos=(2, 3), flag=wx.EXPAND | wx.ALL, border=5)
text4 = wx.StaticText(panel, label="Description")
sizer.Add(text4, pos=(3, 0), flag=wx.ALL, border=5)
tc4 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc4, pos=(3, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
sizer.AddGrowableRow(3)
buttonOk = wx.Button(panel, label="Ok")
buttonClose = wx.Button(panel, label="Close")
sizer.Add(buttonOk, pos=(4, 2), flag=wx.ALL, border=5)
sizer.Add(buttonClose, pos=(4, 3), flag=wx.ALL, border=5)
panel.SetSizerAndFit(sizer)
app = wx.App()
Example(None, title='GridBag Demo')
app.MainLoop()
Here the result is
What make me confused is the label address2
.It does not span three columns obviously.
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
But the code of address2
label is same with address
label except param pos
.Can someone explain this.
env: python3.7/wxpython4.0.4(newest)
python wxpython
add a comment |
I am new with python GUI and wxpython
also. Now im facing following problem.
Here the code is
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title)
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self)
sizer = wx.GridBagSizer(0, 0)
text = wx.StaticText(panel, label="Name:")
sizer.Add(text, pos=(0, 0), flag=wx.ALL, border=5)
tc = wx.TextCtrl(panel)
sizer.Add(tc, pos=(0, 1), span=(1, 2), flag=wx.EXPAND | wx.ALL, border=5)
text1 = wx.StaticText(panel, label="address")
sizer.Add(text1, pos=(1, 0), flag=wx.ALL, border=5)
tc1 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc1, pos=(1, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text2 = wx.StaticText(panel, label="age")
sizer.Add(text2, pos=(2, 0), flag=wx.ALL, border=5)
tc2 = wx.TextCtrl(panel)
sizer.Add(tc2, pos=(2, 1), flag=wx.ALL, border=5)
text3 = wx.StaticText(panel, label="Mob.No")
sizer.Add(text3, pos=(2, 2), flag=wx.ALIGN_CENTER | wx.ALL, border=5)
tc3 = wx.TextCtrl(panel)
sizer.Add(tc3, pos=(2, 3), flag=wx.EXPAND | wx.ALL, border=5)
text4 = wx.StaticText(panel, label="Description")
sizer.Add(text4, pos=(3, 0), flag=wx.ALL, border=5)
tc4 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc4, pos=(3, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
sizer.AddGrowableRow(3)
buttonOk = wx.Button(panel, label="Ok")
buttonClose = wx.Button(panel, label="Close")
sizer.Add(buttonOk, pos=(4, 2), flag=wx.ALL, border=5)
sizer.Add(buttonClose, pos=(4, 3), flag=wx.ALL, border=5)
panel.SetSizerAndFit(sizer)
app = wx.App()
Example(None, title='GridBag Demo')
app.MainLoop()
Here the result is
What make me confused is the label address2
.It does not span three columns obviously.
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
But the code of address2
label is same with address
label except param pos
.Can someone explain this.
env: python3.7/wxpython4.0.4(newest)
python wxpython
I am new with python GUI and wxpython
also. Now im facing following problem.
Here the code is
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title)
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self)
sizer = wx.GridBagSizer(0, 0)
text = wx.StaticText(panel, label="Name:")
sizer.Add(text, pos=(0, 0), flag=wx.ALL, border=5)
tc = wx.TextCtrl(panel)
sizer.Add(tc, pos=(0, 1), span=(1, 2), flag=wx.EXPAND | wx.ALL, border=5)
text1 = wx.StaticText(panel, label="address")
sizer.Add(text1, pos=(1, 0), flag=wx.ALL, border=5)
tc1 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc1, pos=(1, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text2 = wx.StaticText(panel, label="age")
sizer.Add(text2, pos=(2, 0), flag=wx.ALL, border=5)
tc2 = wx.TextCtrl(panel)
sizer.Add(tc2, pos=(2, 1), flag=wx.ALL, border=5)
text3 = wx.StaticText(panel, label="Mob.No")
sizer.Add(text3, pos=(2, 2), flag=wx.ALIGN_CENTER | wx.ALL, border=5)
tc3 = wx.TextCtrl(panel)
sizer.Add(tc3, pos=(2, 3), flag=wx.EXPAND | wx.ALL, border=5)
text4 = wx.StaticText(panel, label="Description")
sizer.Add(text4, pos=(3, 0), flag=wx.ALL, border=5)
tc4 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc4, pos=(3, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
sizer.AddGrowableRow(3)
buttonOk = wx.Button(panel, label="Ok")
buttonClose = wx.Button(panel, label="Close")
sizer.Add(buttonOk, pos=(4, 2), flag=wx.ALL, border=5)
sizer.Add(buttonClose, pos=(4, 3), flag=wx.ALL, border=5)
panel.SetSizerAndFit(sizer)
app = wx.App()
Example(None, title='GridBag Demo')
app.MainLoop()
Here the result is
What make me confused is the label address2
.It does not span three columns obviously.
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
But the code of address2
label is same with address
label except param pos
.Can someone explain this.
env: python3.7/wxpython4.0.4(newest)
python wxpython
python wxpython
asked Mar 8 at 15:04
放課後放課後
348310
348310
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
What is the definition of those 3 columns?
Have you defined anything for columns 5,6 and 7 for the sizer
to work with?
Without something to work with the sizer has no idea how big those columns are, so you must either give it something to work with or define an empty cell size.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title, size=(750,-1))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self, -1)
sizer = wx.GridBagSizer(0, 7)
text = wx.StaticText(panel, label="Name:")
sizer.Add(text, pos=(0, 0), flag=wx.ALL, border=5)
#
# place some dummy text to give the sizer something to work with
#
# dummy4 = wx.StaticText(panel, label="something")
# sizer.Add(dummy4, pos=(0, 4), flag=wx.ALL, border=5)
# dummy5 = wx.StaticText(panel, label="something")
# sizer.Add(dummy5, pos=(0, 5), flag=wx.ALL, border=5)
# dummy6 = wx.StaticText(panel, label="something")
# sizer.Add(dummy6, pos=(0, 6), flag=wx.ALL, border=5)
# dummy7 = wx.StaticText(panel, label="something")
# sizer.Add(dummy7, pos=(0, 7), flag=wx.ALL, border=5)
#
# or set a cell size for empty cells
#
sizer.SetEmptyCellSize((130,20))
tc = wx.TextCtrl(panel)
sizer.Add(tc, pos=(0, 1), span=(1, 2), flag=wx.EXPAND | wx.ALL, border=5)
text1 = wx.StaticText(panel, label="address")
sizer.Add(text1, pos=(1, 0), flag=wx.ALL, border=5)
tc1 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc1, pos=(1, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text2 = wx.StaticText(panel, label="age")
sizer.Add(text2, pos=(2, 0), flag=wx.ALL, border=5)
tc2 = wx.TextCtrl(panel)
sizer.Add(tc2, pos=(2, 1), flag=wx.ALL, border=5)
text3 = wx.StaticText(panel, label="Mob.No")
sizer.Add(text3, pos=(2, 2), flag=wx.ALIGN_CENTER | wx.ALL, border=5)
tc3 = wx.TextCtrl(panel)
sizer.Add(tc3, pos=(2, 3), flag=wx.EXPAND | wx.ALL, border=5)
text4 = wx.StaticText(panel, label="Description")
sizer.Add(text4, pos=(3, 0), flag=wx.ALL, border=5)
tc4 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc4, pos=(3, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
sizer.AddGrowableRow(3)
buttonOk = wx.Button(panel, label="Ok")
buttonClose = wx.Button(panel, label="Close")
sizer.Add(buttonOk, pos=(4, 2), flag=wx.ALL, border=5)
sizer.Add(buttonClose, pos=(4, 3), flag=wx.ALL, border=5)
panel.SetSizerAndFit(sizer)
app = wx.App()
Example(None, title='GridBag Demo')
app.MainLoop()
p.s. The layout would probably work better if you simply placed address2 underneath address 1
thanks for reply and it was right.this the empty cell caused that.But i still have two questions.1.is the cell size in GridBagSizer dynamic? 2.can i set default size of the cell(not the empty cell)?
– 放課後
Mar 9 at 13:19
@放課後 docs.wxpython.org/wx.Sizer.html#wx.Sizer and docs.wxpython.org/wx.GridBagSizer.html#wx.GridBagSizer -- - The default empty cell size appears to be 10 wide and 20 high
– Rolf of Saxony
Mar 9 at 16:47
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55065926%2fwxpython-the-gridbagsizer-made-me-confused%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
What is the definition of those 3 columns?
Have you defined anything for columns 5,6 and 7 for the sizer
to work with?
Without something to work with the sizer has no idea how big those columns are, so you must either give it something to work with or define an empty cell size.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title, size=(750,-1))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self, -1)
sizer = wx.GridBagSizer(0, 7)
text = wx.StaticText(panel, label="Name:")
sizer.Add(text, pos=(0, 0), flag=wx.ALL, border=5)
#
# place some dummy text to give the sizer something to work with
#
# dummy4 = wx.StaticText(panel, label="something")
# sizer.Add(dummy4, pos=(0, 4), flag=wx.ALL, border=5)
# dummy5 = wx.StaticText(panel, label="something")
# sizer.Add(dummy5, pos=(0, 5), flag=wx.ALL, border=5)
# dummy6 = wx.StaticText(panel, label="something")
# sizer.Add(dummy6, pos=(0, 6), flag=wx.ALL, border=5)
# dummy7 = wx.StaticText(panel, label="something")
# sizer.Add(dummy7, pos=(0, 7), flag=wx.ALL, border=5)
#
# or set a cell size for empty cells
#
sizer.SetEmptyCellSize((130,20))
tc = wx.TextCtrl(panel)
sizer.Add(tc, pos=(0, 1), span=(1, 2), flag=wx.EXPAND | wx.ALL, border=5)
text1 = wx.StaticText(panel, label="address")
sizer.Add(text1, pos=(1, 0), flag=wx.ALL, border=5)
tc1 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc1, pos=(1, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text2 = wx.StaticText(panel, label="age")
sizer.Add(text2, pos=(2, 0), flag=wx.ALL, border=5)
tc2 = wx.TextCtrl(panel)
sizer.Add(tc2, pos=(2, 1), flag=wx.ALL, border=5)
text3 = wx.StaticText(panel, label="Mob.No")
sizer.Add(text3, pos=(2, 2), flag=wx.ALIGN_CENTER | wx.ALL, border=5)
tc3 = wx.TextCtrl(panel)
sizer.Add(tc3, pos=(2, 3), flag=wx.EXPAND | wx.ALL, border=5)
text4 = wx.StaticText(panel, label="Description")
sizer.Add(text4, pos=(3, 0), flag=wx.ALL, border=5)
tc4 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc4, pos=(3, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
sizer.AddGrowableRow(3)
buttonOk = wx.Button(panel, label="Ok")
buttonClose = wx.Button(panel, label="Close")
sizer.Add(buttonOk, pos=(4, 2), flag=wx.ALL, border=5)
sizer.Add(buttonClose, pos=(4, 3), flag=wx.ALL, border=5)
panel.SetSizerAndFit(sizer)
app = wx.App()
Example(None, title='GridBag Demo')
app.MainLoop()
p.s. The layout would probably work better if you simply placed address2 underneath address 1
thanks for reply and it was right.this the empty cell caused that.But i still have two questions.1.is the cell size in GridBagSizer dynamic? 2.can i set default size of the cell(not the empty cell)?
– 放課後
Mar 9 at 13:19
@放課後 docs.wxpython.org/wx.Sizer.html#wx.Sizer and docs.wxpython.org/wx.GridBagSizer.html#wx.GridBagSizer -- - The default empty cell size appears to be 10 wide and 20 high
– Rolf of Saxony
Mar 9 at 16:47
add a comment |
What is the definition of those 3 columns?
Have you defined anything for columns 5,6 and 7 for the sizer
to work with?
Without something to work with the sizer has no idea how big those columns are, so you must either give it something to work with or define an empty cell size.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title, size=(750,-1))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self, -1)
sizer = wx.GridBagSizer(0, 7)
text = wx.StaticText(panel, label="Name:")
sizer.Add(text, pos=(0, 0), flag=wx.ALL, border=5)
#
# place some dummy text to give the sizer something to work with
#
# dummy4 = wx.StaticText(panel, label="something")
# sizer.Add(dummy4, pos=(0, 4), flag=wx.ALL, border=5)
# dummy5 = wx.StaticText(panel, label="something")
# sizer.Add(dummy5, pos=(0, 5), flag=wx.ALL, border=5)
# dummy6 = wx.StaticText(panel, label="something")
# sizer.Add(dummy6, pos=(0, 6), flag=wx.ALL, border=5)
# dummy7 = wx.StaticText(panel, label="something")
# sizer.Add(dummy7, pos=(0, 7), flag=wx.ALL, border=5)
#
# or set a cell size for empty cells
#
sizer.SetEmptyCellSize((130,20))
tc = wx.TextCtrl(panel)
sizer.Add(tc, pos=(0, 1), span=(1, 2), flag=wx.EXPAND | wx.ALL, border=5)
text1 = wx.StaticText(panel, label="address")
sizer.Add(text1, pos=(1, 0), flag=wx.ALL, border=5)
tc1 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc1, pos=(1, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text2 = wx.StaticText(panel, label="age")
sizer.Add(text2, pos=(2, 0), flag=wx.ALL, border=5)
tc2 = wx.TextCtrl(panel)
sizer.Add(tc2, pos=(2, 1), flag=wx.ALL, border=5)
text3 = wx.StaticText(panel, label="Mob.No")
sizer.Add(text3, pos=(2, 2), flag=wx.ALIGN_CENTER | wx.ALL, border=5)
tc3 = wx.TextCtrl(panel)
sizer.Add(tc3, pos=(2, 3), flag=wx.EXPAND | wx.ALL, border=5)
text4 = wx.StaticText(panel, label="Description")
sizer.Add(text4, pos=(3, 0), flag=wx.ALL, border=5)
tc4 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc4, pos=(3, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
sizer.AddGrowableRow(3)
buttonOk = wx.Button(panel, label="Ok")
buttonClose = wx.Button(panel, label="Close")
sizer.Add(buttonOk, pos=(4, 2), flag=wx.ALL, border=5)
sizer.Add(buttonClose, pos=(4, 3), flag=wx.ALL, border=5)
panel.SetSizerAndFit(sizer)
app = wx.App()
Example(None, title='GridBag Demo')
app.MainLoop()
p.s. The layout would probably work better if you simply placed address2 underneath address 1
thanks for reply and it was right.this the empty cell caused that.But i still have two questions.1.is the cell size in GridBagSizer dynamic? 2.can i set default size of the cell(not the empty cell)?
– 放課後
Mar 9 at 13:19
@放課後 docs.wxpython.org/wx.Sizer.html#wx.Sizer and docs.wxpython.org/wx.GridBagSizer.html#wx.GridBagSizer -- - The default empty cell size appears to be 10 wide and 20 high
– Rolf of Saxony
Mar 9 at 16:47
add a comment |
What is the definition of those 3 columns?
Have you defined anything for columns 5,6 and 7 for the sizer
to work with?
Without something to work with the sizer has no idea how big those columns are, so you must either give it something to work with or define an empty cell size.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title, size=(750,-1))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self, -1)
sizer = wx.GridBagSizer(0, 7)
text = wx.StaticText(panel, label="Name:")
sizer.Add(text, pos=(0, 0), flag=wx.ALL, border=5)
#
# place some dummy text to give the sizer something to work with
#
# dummy4 = wx.StaticText(panel, label="something")
# sizer.Add(dummy4, pos=(0, 4), flag=wx.ALL, border=5)
# dummy5 = wx.StaticText(panel, label="something")
# sizer.Add(dummy5, pos=(0, 5), flag=wx.ALL, border=5)
# dummy6 = wx.StaticText(panel, label="something")
# sizer.Add(dummy6, pos=(0, 6), flag=wx.ALL, border=5)
# dummy7 = wx.StaticText(panel, label="something")
# sizer.Add(dummy7, pos=(0, 7), flag=wx.ALL, border=5)
#
# or set a cell size for empty cells
#
sizer.SetEmptyCellSize((130,20))
tc = wx.TextCtrl(panel)
sizer.Add(tc, pos=(0, 1), span=(1, 2), flag=wx.EXPAND | wx.ALL, border=5)
text1 = wx.StaticText(panel, label="address")
sizer.Add(text1, pos=(1, 0), flag=wx.ALL, border=5)
tc1 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc1, pos=(1, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text2 = wx.StaticText(panel, label="age")
sizer.Add(text2, pos=(2, 0), flag=wx.ALL, border=5)
tc2 = wx.TextCtrl(panel)
sizer.Add(tc2, pos=(2, 1), flag=wx.ALL, border=5)
text3 = wx.StaticText(panel, label="Mob.No")
sizer.Add(text3, pos=(2, 2), flag=wx.ALIGN_CENTER | wx.ALL, border=5)
tc3 = wx.TextCtrl(panel)
sizer.Add(tc3, pos=(2, 3), flag=wx.EXPAND | wx.ALL, border=5)
text4 = wx.StaticText(panel, label="Description")
sizer.Add(text4, pos=(3, 0), flag=wx.ALL, border=5)
tc4 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc4, pos=(3, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
sizer.AddGrowableRow(3)
buttonOk = wx.Button(panel, label="Ok")
buttonClose = wx.Button(panel, label="Close")
sizer.Add(buttonOk, pos=(4, 2), flag=wx.ALL, border=5)
sizer.Add(buttonClose, pos=(4, 3), flag=wx.ALL, border=5)
panel.SetSizerAndFit(sizer)
app = wx.App()
Example(None, title='GridBag Demo')
app.MainLoop()
p.s. The layout would probably work better if you simply placed address2 underneath address 1
What is the definition of those 3 columns?
Have you defined anything for columns 5,6 and 7 for the sizer
to work with?
Without something to work with the sizer has no idea how big those columns are, so you must either give it something to work with or define an empty cell size.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title, size=(750,-1))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self, -1)
sizer = wx.GridBagSizer(0, 7)
text = wx.StaticText(panel, label="Name:")
sizer.Add(text, pos=(0, 0), flag=wx.ALL, border=5)
#
# place some dummy text to give the sizer something to work with
#
# dummy4 = wx.StaticText(panel, label="something")
# sizer.Add(dummy4, pos=(0, 4), flag=wx.ALL, border=5)
# dummy5 = wx.StaticText(panel, label="something")
# sizer.Add(dummy5, pos=(0, 5), flag=wx.ALL, border=5)
# dummy6 = wx.StaticText(panel, label="something")
# sizer.Add(dummy6, pos=(0, 6), flag=wx.ALL, border=5)
# dummy7 = wx.StaticText(panel, label="something")
# sizer.Add(dummy7, pos=(0, 7), flag=wx.ALL, border=5)
#
# or set a cell size for empty cells
#
sizer.SetEmptyCellSize((130,20))
tc = wx.TextCtrl(panel)
sizer.Add(tc, pos=(0, 1), span=(1, 2), flag=wx.EXPAND | wx.ALL, border=5)
text1 = wx.StaticText(panel, label="address")
sizer.Add(text1, pos=(1, 0), flag=wx.ALL, border=5)
tc1 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc1, pos=(1, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text11 = wx.StaticText(panel, label="address2")
sizer.Add(text11, pos=(1, 4), flag=wx.ALL, border=5)
tc11 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc11, pos=(1, 5), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
text2 = wx.StaticText(panel, label="age")
sizer.Add(text2, pos=(2, 0), flag=wx.ALL, border=5)
tc2 = wx.TextCtrl(panel)
sizer.Add(tc2, pos=(2, 1), flag=wx.ALL, border=5)
text3 = wx.StaticText(panel, label="Mob.No")
sizer.Add(text3, pos=(2, 2), flag=wx.ALIGN_CENTER | wx.ALL, border=5)
tc3 = wx.TextCtrl(panel)
sizer.Add(tc3, pos=(2, 3), flag=wx.EXPAND | wx.ALL, border=5)
text4 = wx.StaticText(panel, label="Description")
sizer.Add(text4, pos=(3, 0), flag=wx.ALL, border=5)
tc4 = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
sizer.Add(tc4, pos=(3, 1), span=(1, 3), flag=wx.EXPAND | wx.ALL, border=5)
sizer.AddGrowableRow(3)
buttonOk = wx.Button(panel, label="Ok")
buttonClose = wx.Button(panel, label="Close")
sizer.Add(buttonOk, pos=(4, 2), flag=wx.ALL, border=5)
sizer.Add(buttonClose, pos=(4, 3), flag=wx.ALL, border=5)
panel.SetSizerAndFit(sizer)
app = wx.App()
Example(None, title='GridBag Demo')
app.MainLoop()
p.s. The layout would probably work better if you simply placed address2 underneath address 1
answered Mar 9 at 9:29
Rolf of SaxonyRolf of Saxony
9,63522038
9,63522038
thanks for reply and it was right.this the empty cell caused that.But i still have two questions.1.is the cell size in GridBagSizer dynamic? 2.can i set default size of the cell(not the empty cell)?
– 放課後
Mar 9 at 13:19
@放課後 docs.wxpython.org/wx.Sizer.html#wx.Sizer and docs.wxpython.org/wx.GridBagSizer.html#wx.GridBagSizer -- - The default empty cell size appears to be 10 wide and 20 high
– Rolf of Saxony
Mar 9 at 16:47
add a comment |
thanks for reply and it was right.this the empty cell caused that.But i still have two questions.1.is the cell size in GridBagSizer dynamic? 2.can i set default size of the cell(not the empty cell)?
– 放課後
Mar 9 at 13:19
@放課後 docs.wxpython.org/wx.Sizer.html#wx.Sizer and docs.wxpython.org/wx.GridBagSizer.html#wx.GridBagSizer -- - The default empty cell size appears to be 10 wide and 20 high
– Rolf of Saxony
Mar 9 at 16:47
thanks for reply and it was right.this the empty cell caused that.But i still have two questions.1.is the cell size in GridBagSizer dynamic? 2.can i set default size of the cell(not the empty cell)?
– 放課後
Mar 9 at 13:19
thanks for reply and it was right.this the empty cell caused that.But i still have two questions.1.is the cell size in GridBagSizer dynamic? 2.can i set default size of the cell(not the empty cell)?
– 放課後
Mar 9 at 13:19
@放課後 docs.wxpython.org/wx.Sizer.html#wx.Sizer and docs.wxpython.org/wx.GridBagSizer.html#wx.GridBagSizer -- - The default empty cell size appears to be 10 wide and 20 high
– Rolf of Saxony
Mar 9 at 16:47
@放課後 docs.wxpython.org/wx.Sizer.html#wx.Sizer and docs.wxpython.org/wx.GridBagSizer.html#wx.GridBagSizer -- - The default empty cell size appears to be 10 wide and 20 high
– Rolf of Saxony
Mar 9 at 16:47
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55065926%2fwxpython-the-gridbagsizer-made-me-confused%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown