Единственный способ, которым я могу придумать, - это использовать BitmapButton
, который вы подготовили.
Вы можете сделать это программно, например,
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=(400, 300))
panel = wx.Panel(self)
#Create an image
simg = wx.Image(150,25,True)
#Change from black to grey
simg.Replace(0,0,0,200,200,200)
bitmap = simg.ConvertToBitmap()
#Write required text
dc = wx.MemoryDC(bitmap)
dc.SetTextForeground(wx.BLACK)
dc.DrawText("Vertical Button", 10, 0)
del dc
img = bitmap.ConvertToImage()
img1 = img.Rotate90(False)
img2 = img.Rotate90()
bmp = img1.ConvertToBitmap()
bmp2 = img2.ConvertToBitmap()
btn1 = wx.BitmapButton(panel, -1, bmp, pos=(10,10))
btn2 = wx.BitmapButton(panel, -1, bmp2, pos=(350,10))
btn1.Bind(wx.EVT_BUTTON, self.BTN1)
btn2.Bind(wx.EVT_BUTTON, self.BTN2)
#Just for fun create a button with vertical text
simg = wx.Image(25,110,True)
#Change from black to grey
simg.Replace(0,0,0,200,200,200)
bitmap = simg.ConvertToBitmap()
#Write required text
dc = wx.MemoryDC(bitmap)
dc.SetTextForeground(wx.BLACK)
dc.DrawText("V", 7, 0)
dc.DrawText("e", 8, 15)
dc.DrawText("r", 8, 30)
dc.DrawText("t", 8, 45)
dc.DrawText("i", 8, 60)
dc.DrawText("c", 8, 75)
dc.DrawText("l", 8, 90)
del dc
img3 = bitmap.ConvertToImage()
bmp3 = img3.ConvertToBitmap()
btn3 = wx.BitmapButton(panel, -1, bmp3, pos=(175,10))
btn3.Bind(wx.EVT_BUTTON, self.BTN3)
def BTN1(self,event):
print("Left Button")
def BTN2(self,event):
print("Right Button")
def BTN3(self,event):
print("Middle Button")
app = wx.App()
frame = MyFrame(None, 'Vertical Buttons')
frame.Show()
app.MainLoop()