Create a class to position a window on the screen.

Zac Burns zac256 at gmail.com
Mon Jan 10 10:00:47 EST 2011


I'm not exactly sure what you are asking here, but one problem that is
notable in your example is that the center function is indented inside the
__init__ function. This would create a closure instead of a method on
PositionWindow, which is probably not what you want.

-Zac



On Sun, Jan 9, 2011 at 10:23 AM, Rohit Coder <
passionate_programmer at hotmail.com> wrote:

>  Hi,
> elementFontfont-familyfont-sizefont-stylefont-variantfont-weight
> letter-spacingline-heighttext-decorationtext-aligntext-indent
> text-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-color
> bg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-right
> border-bottomborder-leftmarginpaddingmax-heightmin-heightmax-width
> min-widthoutline-coloroutline-styleoutline-widthPositioningpositiontop
> bottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-type
> list-style-positionTablevertical-alignborder-collapseborder-spacing
> caption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadow
> border-radiusOtheroverflowcursorvisibility
>
> I am new to Python and this is my fist Python class. I am using PyQt4
> framework on Windows 7.
>
> I don't know whether the code below is correctly written or not. I want to
> modify it further as:
>
>  1. In the arguments, I want to pass the name of another opened Window
> (.py) on the screen.
>  2. I want to pass the x-coord., y-coord. and the name of the window to
> position on the screen.
>
> How to modify the code to fulfill these requirements?
>
> ***Attempted Code***
>
>     class PositionWindow:
>         def __init__(self, xCoord, yCoord, windowName, parent = None):
>           self.x = xCoord
>           self.y = yCoord
>           self.wName = windowName;
>
>           def center(self):
>             screen = QtGui.QDesktopWidget().screenGeometry()
>             size = self.geometry()
>             self.move((screen.width()-size.width())/2,
> (screen.height()-size.height())/2)
>
> ...................
> Rohit.
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110110/0b7e987d/attachment-0001.html>


More information about the Python-list mailing list