user1416451
user1416451

Reputation:

How do i apply wx.NO_BORDER without ruining my program?

i want no border around my program but whenever i set wx.NO_BORDER to the frame i get this little blue box and it takes everything with it.

how can i set wx.no_border without it wrecking everything?

i have tried everything!

thanks.

code:

import wx
class nGUI(wx.Frame):
  def __init__(self,parent,id):
    wx.Frame.__init__(self,parent,id,size=(500,160),style=wx.DEFAULT_FRAME_STYLE & wx.NO_BORDER & ~wx.SYSTEM_MENU)
    panel=wx.Panel(self)
    self.Centre()
    image_file = '../nGFX/nPySlim.png'
    bmp1 = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
    panel.bitmap1 = wx.StaticBitmap(panel, -1, bmp1, (0, 0))
    textbox = wx.TextCtrl(panel.bitmap1, -1, pos=(245,50), size=(210, 28))
    font = wx.Font(14,wx.FONTFAMILY_SWISS,wx.FONTSTYLE_SLANT,wx.FONTWEIGHT_NORMAL)
    textbox.SetFont(font)
    wx.Button(panel.bitmap1, -1, pos=(413,90), size=(60, 25), label="Generate")

if __name__=='__main__':
  app=wx.PySimpleApp()
  frame=nGUI(parent=None,id=-1)
  frame.Show()
  app.MainLoop()

Upvotes: 1

Views: 1365

Answers (2)

GP89
GP89

Reputation: 6730

you need to use | add styles, and ^ to remove them

so wx.DEFAULT_FRAME_STYLE | wx.NO_BORDER ^ wx.SYSTEM_MENU

Upvotes: 2

jadkik94
jadkik94

Reputation: 7068

I don't know why your program only failed with the wx.NO_BORDER flag, but the issue was not there for me.

However I run it, I got a segmentation fault (which indicates there is something wrong with wxPython's C code)

The problem was that the parent of the textbox and wx.Button was panel.bitmap1, while it was supposed to be panel. And it makes sense, because the Bitmap is not meant to have child items. The weird thing is how it failed, and that's a problem with wx.

I'm running this version of wxPython: 2.8.12.1 (gtk2-unicode) on Python 2.7. It might be important, considering that the problem was with wxPython itself.

Upvotes: 0

Related Questions