How to change the position of the bitmap button?

Asked

Viewed 147 times

3

I inserted a button with an image in my menu. But I can’t change its position. How do I change its position? because I need to insert 2 more buttons and organize them.I’m using the python wx library.

menu image: inserir a descrição da imagem aqui

code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import wx
import wx.lib.buttons


class Frame(wx.Frame):
    title = "SEA - SunPy Environment Application"
    def __init__(self):
        wx.Frame.__init__(self, None, title=self.title, size=(800, 600))
        self.panel1 = wx.Panel(self, -1)
        self.createMainPanel()
        self.createMainMenu()


    def createMainPanel(self, color=(0, 0, 0)):
        panel = wx.Panel(self, id=wx.ID_ANY, pos=(0, 0), size=self.GetSize())
        panel.SetBackgroundColour('GRAY')

        bmp = wx.Bitmap("logo.jpg", wx.BITMAP_TYPE_ANY)
        button = wx.BitmapButton(panel,id=wx.ID_ANY, bitmap=bmp, size=(bmp.GetWidth()+10, bmp.GetHeight()+10))

        self.Centre()

    def OnPaint(self, event):
        dc = wx.PaintDC(self)
        dc.DrawBitmap(self.bitmap, 60, 20)

    def onQuit(self, event):
        self.Close()

class App(wx.App):
    def OnInit(self):
        self.mainScreen = Frame()
        self.SetTopWindow(self.mainScreen)
        self.mainScreen.Show()

        return True  

if __name__ == '__main__':
    app = App(False)
    app.MainLoop()
  • How would you like to position them ?

  • @Magichat this button I’d like to position at the top, center. The other two, further down, side by side, like a triangle.

1 answer

2


I added the pos=(300.0) attribute and it worked.

button = wx.Bitmapbutton(panel,id=wx.ID_ANY, pos=(300,0), bitmap=bmp, size=(bmp.Getwidth()+10, bmp.Getheight()+10))

  • In a while you’ll be able to accept the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.