Hitesh Chavda
Hitesh Chavda

Reputation: 789

how to set wxPython main frame bottom right on screen?

For better description,

+-----------------------+
|   Desktop (screen)    |
|                       |
|                       |
|         +----------+  |
|         | wxPython |  |
|         |   App.   |  |
|         |          |  |
|         |          |  |
|         +----------+  |
+-----------------------+

Look at WxPython App., which is align to the bottom right of screen. How to I position my main frame because screen width is different on each pc?

For Better Understanding, I want to pop-up small window like Digsby and FeedNotifier use! i think both use python!!

Upvotes: 7

Views: 7776

Answers (2)

Pedro Sequeira
Pedro Sequeira

Reputation: 137

If you want to avoid covering the taskbar you can use

junk, junk, dw, dh = wx.ClientDisplayRect()

instead of

dw, dh = wx.DisplaySize()

Solution code:

import wx

def alignToBottomRight(win):
    junk, junk, dw, dh = wx.ClientDisplayRect()
    w, h = win.GetSize()
    x = dw - w
    y = dh - h
    win.SetPosition((x, y))

app = wx.PySimpleApp()
frame = wx.MiniFrame(None, title="My PopUp", size=(200,300), style=wx.DEFAULT_MINIFRAME_STYLE|wx.CLOSE_BOX)
alignToBottomRight(frame)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()

Upvotes: 4

Anurag Uniyal
Anurag Uniyal

Reputation: 88737

You can use wx.DisplaySize to get display screen size, and from window.GetSize() you can get the size of your window which you want to position, these two informations are enough to pos it correctly. e.g. in this example I position a MinFrame it at bottom-right

import wx

def alignToBottomRight(win):
    dw, dh = wx.DisplaySize()
    w, h = win.GetSize()
    x = dw - w
    y = dh - h
    win.SetPosition((x, y))

app = wx.PySimpleApp()
frame = wx.MiniFrame(None, title="My PopUp", size=(200,300), style=wx.DEFAULT_MINIFRAME_STYLE|wx.CLOSE_BOX)
alignToBottomRight(frame)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()

Upvotes: 13

Related Questions