What method / methods should be be used in order to get the frame to start up in a central position of the screen, and could you also provide the code please. I'm using wxPython. thanks

Recommended Answers

All 2 Replies

Here you go ...

# a wxPython general frame template

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)
        self.SetBackgroundColour("red")

        # create an input widget
        #
        # bind mouse or key event to an action
        #
        # create an output widget
        #

    def onAction(self, event):
        """ some action code"""
        pass


app = wx.App(0)
# create a MyFrame instance and show the frame
mytitle = 'the title'
width = 400
height = 300
frame = MyFrame(None, mytitle, (width, height))
# his will center the frame in the display area
frame.Center()
frame.Show()
app.MainLoop()

Thanks alot!!! it works beautifully!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.