Trying to fix the position of Buttons
I am trying to change the places of the buttons from left to right at the top.
1)Here is the code below.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title = title, size = (200,300))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
p = wx.Panel(self)
vbox = wx.BoxSizer(wx.VERTICAL)
for label in range(8):
b2 = wx.Button(p, label =str(label))
vbox.Add(b2,0,wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)
for label in range(8):
b3 = wx.Button(p, label = "Btn3")
vbox.Add(b3,0,wx.RIGHT)
hbox = wx.BoxSizer(wx.HORIZONTAL)
p.SetSizer(vbox)
app = wx.App()
Example(None, title = 'BoxSizer demo')
app.MainLoop()
The output is showing like this enter image description here
But i want the btn3 to the right side like this
- 1 btn3
- 2 btn3
- 3 btn3
- 4 btn3
Here (1,2,3,4) are buttons with btn3 (buttons)
Thanks for advance.
python wxpython wxpython-phoenix
add a comment |
I am trying to change the places of the buttons from left to right at the top.
1)Here is the code below.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title = title, size = (200,300))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
p = wx.Panel(self)
vbox = wx.BoxSizer(wx.VERTICAL)
for label in range(8):
b2 = wx.Button(p, label =str(label))
vbox.Add(b2,0,wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)
for label in range(8):
b3 = wx.Button(p, label = "Btn3")
vbox.Add(b3,0,wx.RIGHT)
hbox = wx.BoxSizer(wx.HORIZONTAL)
p.SetSizer(vbox)
app = wx.App()
Example(None, title = 'BoxSizer demo')
app.MainLoop()
The output is showing like this enter image description here
But i want the btn3 to the right side like this
- 1 btn3
- 2 btn3
- 3 btn3
- 4 btn3
Here (1,2,3,4) are buttons with btn3 (buttons)
Thanks for advance.
python wxpython wxpython-phoenix
add a comment |
I am trying to change the places of the buttons from left to right at the top.
1)Here is the code below.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title = title, size = (200,300))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
p = wx.Panel(self)
vbox = wx.BoxSizer(wx.VERTICAL)
for label in range(8):
b2 = wx.Button(p, label =str(label))
vbox.Add(b2,0,wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)
for label in range(8):
b3 = wx.Button(p, label = "Btn3")
vbox.Add(b3,0,wx.RIGHT)
hbox = wx.BoxSizer(wx.HORIZONTAL)
p.SetSizer(vbox)
app = wx.App()
Example(None, title = 'BoxSizer demo')
app.MainLoop()
The output is showing like this enter image description here
But i want the btn3 to the right side like this
- 1 btn3
- 2 btn3
- 3 btn3
- 4 btn3
Here (1,2,3,4) are buttons with btn3 (buttons)
Thanks for advance.
python wxpython wxpython-phoenix
I am trying to change the places of the buttons from left to right at the top.
1)Here is the code below.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title = title, size = (200,300))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
p = wx.Panel(self)
vbox = wx.BoxSizer(wx.VERTICAL)
for label in range(8):
b2 = wx.Button(p, label =str(label))
vbox.Add(b2,0,wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)
for label in range(8):
b3 = wx.Button(p, label = "Btn3")
vbox.Add(b3,0,wx.RIGHT)
hbox = wx.BoxSizer(wx.HORIZONTAL)
p.SetSizer(vbox)
app = wx.App()
Example(None, title = 'BoxSizer demo')
app.MainLoop()
The output is showing like this enter image description here
But i want the btn3 to the right side like this
- 1 btn3
- 2 btn3
- 3 btn3
- 4 btn3
Here (1,2,3,4) are buttons with btn3 (buttons)
Thanks for advance.
python wxpython wxpython-phoenix
python wxpython wxpython-phoenix
edited Nov 21 '18 at 18:39
Rolf of Saxony
8,60521637
8,60521637
asked Nov 21 '18 at 13:43
vinay doddapaneni
54
54
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I assume that you want the btn3
buttons in a vertical line to the right of the other buttons.
There are various options, GridSizer
and FlexGridSizer
spring to mind but in your code you have already introduced a horizontal BoxSizer
but not used it, so this code below will use that.
Load the vertical boxsizers and then load those into the horizontal sizer.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title = title, size = (200,300))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
p = wx.Panel(self)
vbox1 = wx.BoxSizer(wx.VERTICAL)
vbox2 = wx.BoxSizer(wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)
for label in range(8):
b2 = wx.Button(p, label =str(label))
vbox1.Add(b2,0,0)
for label in range(8):
b3 = wx.Button(p, label = "Btn3")
vbox2.Add(b3,0,0)
hbox.Add(vbox1)
hbox.Add(vbox2)
p.SetSizer(hbox)
app = wx.App()
Example(None, title = 'BoxSizer demo')
app.MainLoop()
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%2f53413418%2ftrying-to-fix-the-position-of-buttons%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
I assume that you want the btn3
buttons in a vertical line to the right of the other buttons.
There are various options, GridSizer
and FlexGridSizer
spring to mind but in your code you have already introduced a horizontal BoxSizer
but not used it, so this code below will use that.
Load the vertical boxsizers and then load those into the horizontal sizer.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title = title, size = (200,300))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
p = wx.Panel(self)
vbox1 = wx.BoxSizer(wx.VERTICAL)
vbox2 = wx.BoxSizer(wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)
for label in range(8):
b2 = wx.Button(p, label =str(label))
vbox1.Add(b2,0,0)
for label in range(8):
b3 = wx.Button(p, label = "Btn3")
vbox2.Add(b3,0,0)
hbox.Add(vbox1)
hbox.Add(vbox2)
p.SetSizer(hbox)
app = wx.App()
Example(None, title = 'BoxSizer demo')
app.MainLoop()
add a comment |
I assume that you want the btn3
buttons in a vertical line to the right of the other buttons.
There are various options, GridSizer
and FlexGridSizer
spring to mind but in your code you have already introduced a horizontal BoxSizer
but not used it, so this code below will use that.
Load the vertical boxsizers and then load those into the horizontal sizer.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title = title, size = (200,300))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
p = wx.Panel(self)
vbox1 = wx.BoxSizer(wx.VERTICAL)
vbox2 = wx.BoxSizer(wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)
for label in range(8):
b2 = wx.Button(p, label =str(label))
vbox1.Add(b2,0,0)
for label in range(8):
b3 = wx.Button(p, label = "Btn3")
vbox2.Add(b3,0,0)
hbox.Add(vbox1)
hbox.Add(vbox2)
p.SetSizer(hbox)
app = wx.App()
Example(None, title = 'BoxSizer demo')
app.MainLoop()
add a comment |
I assume that you want the btn3
buttons in a vertical line to the right of the other buttons.
There are various options, GridSizer
and FlexGridSizer
spring to mind but in your code you have already introduced a horizontal BoxSizer
but not used it, so this code below will use that.
Load the vertical boxsizers and then load those into the horizontal sizer.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title = title, size = (200,300))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
p = wx.Panel(self)
vbox1 = wx.BoxSizer(wx.VERTICAL)
vbox2 = wx.BoxSizer(wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)
for label in range(8):
b2 = wx.Button(p, label =str(label))
vbox1.Add(b2,0,0)
for label in range(8):
b3 = wx.Button(p, label = "Btn3")
vbox2.Add(b3,0,0)
hbox.Add(vbox1)
hbox.Add(vbox2)
p.SetSizer(hbox)
app = wx.App()
Example(None, title = 'BoxSizer demo')
app.MainLoop()
I assume that you want the btn3
buttons in a vertical line to the right of the other buttons.
There are various options, GridSizer
and FlexGridSizer
spring to mind but in your code you have already introduced a horizontal BoxSizer
but not used it, so this code below will use that.
Load the vertical boxsizers and then load those into the horizontal sizer.
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title = title, size = (200,300))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
p = wx.Panel(self)
vbox1 = wx.BoxSizer(wx.VERTICAL)
vbox2 = wx.BoxSizer(wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)
for label in range(8):
b2 = wx.Button(p, label =str(label))
vbox1.Add(b2,0,0)
for label in range(8):
b3 = wx.Button(p, label = "Btn3")
vbox2.Add(b3,0,0)
hbox.Add(vbox1)
hbox.Add(vbox2)
p.SetSizer(hbox)
app = wx.App()
Example(None, title = 'BoxSizer demo')
app.MainLoop()
answered Nov 21 '18 at 18:35
Rolf of Saxony
8,60521637
8,60521637
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53413418%2ftrying-to-fix-the-position-of-buttons%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