Exemple #1
0
 def _debug_load_window_layout(
     self
 ):  # [similar code is in pre_main_show in a startup module, new as of 051218]
     win = self._debug_win
     keyprefix = mainwindow_geometry_prefs_key_prefix
     load_window_pos_size(win, keyprefix)
Exemple #2
0
def pre_main_show(win):
    """
    Do whatever should be done after the main window is created
    but before it's first shown.
    """

    # Determine the screen resolution and compute the normal window size for NE-1
    # [bruce 041230 corrected this for Macintosh, and made sure it never exceeds
    #  screen size even on a very small screen.]
    # [bruce 050118 further modified this and removed some older comments
    #  (see cvs for those); also split out some code into platform.py.]
    from platform_dependent.PlatformDependent import screen_pos_size
    ((x0, y0), (screen_w, screen_h)) = screen_pos_size()
    # note: y0 is nonzero on mac, due to menubar at top of screen.

    # use 85% of screen width and 90% of screen height, or more if that would be
    # less than 780 by 560 pixels, but never more than the available space.
    norm_w = int(min(screen_w - 2, max(780, screen_w * 0.85)))
    norm_h = int(min(screen_h - 2, max(560, screen_h * 0.90)))
    #bruce 050118 reduced max norm_h to never overlap mac menubar (bugfix?)

    # determine normal window origin
    # [bruce 041230 changed this to center it, but feel free to change this back
    #  by changing the next line to center_it = 0]
    center_it = 1
    if center_it:
        # centered in available area
        norm_x = (screen_w - norm_w) / 2 + x0
        norm_y = (screen_h - norm_h) / 2 + y0
    else:
        # at the given absolute position within the available area
        # (but moved towards (0,0) from that, if necessary to keep it all on-screen)
        want_x = 4  # Left (4 pixels)
        want_y = 36  # Top (36 pixels)
        norm_x = min(want_x, (screen_w - norm_w)) + x0
        norm_y = min(want_y, (screen_h - norm_h)) + y0

    # Set the main window geometry, hopefully before the caller shows the window
    from PyQt4.Qt import QRect
    win.setGeometry(QRect(norm_x, norm_y, norm_w, norm_h))

    ###e it might be good to register this as the default geom. in the prefs system, and use that to implement "restore defaults"

    # After the above (whose side effects on main window geom. are used as defaults by the following code),
    # load any mainwindow geometry present in prefs db. [bruce 051218 new feature; see also new "save" features in UserPrefs.py]
    from utilities.debug import print_compact_stack
    try:
        # this code is similar to debug.py's _debug_load_window_layout
        from ne1_ui.prefs.Preferences import load_window_pos_size
        from utilities.prefs_constants import mainwindow_geometry_prefs_key_prefix
        keyprefix = mainwindow_geometry_prefs_key_prefix
        load_window_pos_size(win, keyprefix)
        win._ok_to_autosave_geometry_changes = True
    except:
        print_compact_stack(
            "exception while loading/setting main window pos/size from prefs db: "
        )
        win.setGeometry(QRect(norm_x, norm_y, norm_w, norm_h))

    _initialize_custom_display_modes(win)

    ### TODO: this would be a good place to add miscellaneous commands to the UI,
    # provided they are fully supported (not experimental, unlikely to cause bugs when added)
    # and won't take a lot of runtime to add. Otherwise they can be added after the
    # main window is shown. [bruce 071005 comment] ###@@@

    return  # from pre_main_show
Exemple #3
0
def pre_main_show( win):
    """
    Do whatever should be done after the main window is created
    but before it's first shown.
    """

    # Determine the screen resolution and compute the normal window size for NE-1
    # [bruce 041230 corrected this for Macintosh, and made sure it never exceeds
    #  screen size even on a very small screen.]
    # [bruce 050118 further modified this and removed some older comments
    #  (see cvs for those); also split out some code into platform.py.]
    from platform_dependent.PlatformDependent import screen_pos_size
    ((x0, y0), (screen_w, screen_h)) = screen_pos_size()
    # note: y0 is nonzero on mac, due to menubar at top of screen.

    # use 85% of screen width and 90% of screen height, or more if that would be
    # less than 780 by 560 pixels, but never more than the available space.
    norm_w = int( min(screen_w - 2, max(780, screen_w * 0.85)))
    norm_h = int( min(screen_h - 2, max(560, screen_h * 0.90)))
        #bruce 050118 reduced max norm_h to never overlap mac menubar (bugfix?)

    # determine normal window origin
    # [bruce 041230 changed this to center it, but feel free to change this back
    #  by changing the next line to center_it = 0]
    center_it = 1
    if center_it:
        # centered in available area
        norm_x = (screen_w - norm_w) / 2 + x0
        norm_y = (screen_h - norm_h) / 2 + y0
    else:
        # at the given absolute position within the available area
        # (but moved towards (0,0) from that, if necessary to keep it all on-screen)
        want_x = 4 # Left (4 pixels)
        want_y = 36 # Top (36 pixels)
        norm_x = min( want_x, (screen_w - norm_w)) + x0
        norm_y = min( want_y, (screen_h - norm_h)) + y0

    # Set the main window geometry, hopefully before the caller shows the window
    from PyQt4.Qt import QRect
    win.setGeometry(QRect(norm_x, norm_y, norm_w, norm_h))

    ###e it might be good to register this as the default geom. in the prefs system, and use that to implement "restore defaults"

    # After the above (whose side effects on main window geom. are used as defaults by the following code),
    # load any mainwindow geometry present in prefs db. [bruce 051218 new feature; see also new "save" features in UserPrefs.py]
    from utilities.debug import print_compact_stack
    try:
        # this code is similar to debug.py's _debug_load_window_layout
        from ne1_ui.prefs.Preferences import load_window_pos_size
        from utilities.prefs_constants import mainwindow_geometry_prefs_key_prefix
        keyprefix = mainwindow_geometry_prefs_key_prefix
        load_window_pos_size( win, keyprefix)
        win._ok_to_autosave_geometry_changes = True
    except:
        print_compact_stack("exception while loading/setting main window pos/size from prefs db: ")
        win.setGeometry(QRect(norm_x, norm_y, norm_w, norm_h))

    _initialize_custom_display_modes(win)

    ### TODO: this would be a good place to add miscellaneous commands to the UI,
    # provided they are fully supported (not experimental, unlikely to cause bugs when added)
    # and won't take a lot of runtime to add. Otherwise they can be added after the
    # main window is shown. [bruce 071005 comment] ###@@@

    return # from pre_main_show
 def _debug_load_window_layout(self): # [similar code is in pre_main_show in a startup module, new as of 051218]
     win = self._debug_win
     keyprefix = mainwindow_geometry_prefs_key_prefix
     load_window_pos_size( win, keyprefix)