Saturday, 15 June 2013

python - How to determine screen size in matplotlib -


I get the screen size in pixels using matplotlib with an interactive backend (for example TkAgg, Qt4Agg, or) I'm looking for a way. MacSacks).

I am trying to write a function that can open the window on the screen of standard places such as the right half of the screen, or in the right-hand corner.

I wrote a working solution, copied it down, but need to use a full-screen_toggle (), as to create a full-screen window to measure your size .

I am looking for a way to get the screen size without creating a full screen window and then changing its shape.

  import matplotlib.pyplot as plt def move_figure (position = "top-right"): Move the window to a window in the standard set of conditions and resize. Possible conditions are: top, bottom, left, right, top-left, top-right, bottom-left, lower-right '' 'MGR = PLT.Gate_graph ____________________ agerager_ () # Primitive, but works to get screen size Py = mgr.canvas.height () px = mgr.canvas.width () d = 10 # Width of the window border in pixels if position == "top": #x-top-left-corner, y-top- Left corner, x-width, y-width (in pixels) mgr.window.setGeometry (d, 4 * d, px - 2 * d, py / 2 - 4 * d) elif position == "bottom": mgr Window.setGeometry (d, py / 2 + 5 * d, px - 2 * d, py / 2 - 4 * d) elif position == "left": mgr.window.setGeometry (d, 4 * d, px / 2 - 2 * d, py - 4 * d) Elph position == "right": mgr.window.setGeometry (px / 2 + D, 4 * d, px / 2 - 2 * d, py - 4 * d) Alif position == "Upper left": MGR.Windows.Setgetometry (D, 4 * D, PX / 2 -2D, PA / 2 - 4 * D) Elife Status == "Top-Right": MGR.Window.setGeometry (px / 2 + d, 4 * d, px / 2 - 2 * d, py / 2 - 4 * d) Elph position = "bottom-left": MGR.wondo.set gemetry (D, PA / 2 + 5 * D, Px / 2-2D, PA / 2 - 4 * D) Alief position == "Bottom-right ": MGR .Window.setGeometry (px / 2 + d, py / 2 + 5 * d, px / 2 - 2 * d, py / 2 - 4 * d) If __na Use_button_pigure ("top-right") plt.figure (2) plt.plot ([0, 3])   Pt.figure (1) plt.plot ([0, 1] code>   

This OS X Works for:

  Import AppKit [(Screen.frame (). Size.width, screen.frame () Size.height) for screen in AppKit.NSScreen.screens ()]  

Apple document on class.


No comments:

Post a Comment