44. gui.guimain
— Graphical User Interface for pyFormex.¶
This module contains the main functions responsible for constructing and starting the pyFormex GUI.
44.1. Classes defined in module gui.guimain¶
-
class
gui.guimain.
Board
(parent=None)[source]¶ Message board for displaying read-only plain text messages.
-
class
gui.guimain.
FileWatcher
(*args)[source]¶ Watch for changes in files and then execute the associated function.
-
class
gui.guimain.
Gui
(windowname, size=(800, 600), pos=(0, 0), bdsize=(0, 0))[source]¶ Implements a GUI for pyformex.
-
createConsole
(config)[source]¶ Create the message board and console
config should be one of the following:
‘b’ : only board, no console ‘bc’: a board and separate console ‘c’ : only console, taking ove the board functions
-
clearViewButtons
()[source]¶ Clear the view buttons in views toolbar and views menu.
This is typically use from setViewButtons to change the current buttons to a new set.
-
setViewButtons
(defviews)[source]¶ Set view buttons in views toolbar and views menu.
defviews can be on of ‘xy’ or ‘xz’, or else it is a list of tuple (viewname, viewicon)
-
createView
(name, angles)[source]¶ Create a new view and add it to the list of predefined views.
This creates a named view with specified angles or, if the name already exists, changes its angles to the new values.
It adds the view to the views Menu and Toolbar, if these exist and do not have the name yet.
-
saveView
(name=None, addtogui=True)[source]¶ Save the current view and optionally create a button for it.
This saves the current viewport ModelView and Projection matrices under the specified name.
It adds the view to the views Menu and Toolbar, if these exist and do not have the name yet.
-
setView
(view)[source]¶ Change the view of the current GUI viewport, keeping the bbox.
view is the name of one of the defined views.
-
updateToolBar
(shortname, fullname=None)[source]¶ Add a toolbar or change its position.
This function adds a toolbar to the GUI main window at the position specified in the configuration. If the toolbar already exists, it is moved from its previous location to the requested position. If the toolbar does not exist, it is created with the given fullname, or the shortname by default.
The full name is the name as displayed to the user. The short name is the name as used in the config settings.
The config setting for the toolbar determines its placement: - None: the toolbar is not created - ‘left’, ‘right’, ‘top’ or ‘bottom’: a separate toolbar is created - ‘default’: the default top toolbar is used and a separator is added.
-
maxCanvasSize
()[source]¶ Return the maximum canvas size.
The maximum canvas size is the size of the central space in the main window, occupied by the OpenGL viewports.
-
setcurfile
(appname)[source]¶ Set the current application or script.
appname is either an application module name or a script file.
-
resetCursor
()[source]¶ Clear the override cursor stack.
This will reset the application cursor to the initial default.
-
keyPressEvent
(e)[source]¶ Top level key press event handler.
Events get here if they are not handled by a lower level handler. Every key press arriving here generates a WAKEUP signal, and if a dedicated signal for the key was installed in the keypress table, that signal is emitted too. Finally, the event is removed.
-
XPos
()[source]¶ Get the main window position from the xwininfo command.
The Qt position does not get updated when changing the window size from the left. This substitute function will find the correct position from the xwininfo command output.
-
findDialog
(name)[source]¶ Find the InputDialog with the specified name.
Returns the list with maching dialogs, possibly empty.
-
closeDialog
(name)[source]¶ Close the InputDialog with the specified name.
Closest all the InputDialogs with the specified caption owned by the GUI.
-
enableButtons
(toolbar, buttons, enable)[source]¶ Enable or disable a button in a toolbar.
toolbar is a toolbar dict. buttons is a list of button names. For each button in the list:
- If it exists in toolbar, en/disables the button.
- Else does nothing
-
startRun
()[source]¶ Change the GUI when an app/script starts running.
This method enables/disables the parts of the GUI that should or should not be available while a script is running It is called by the application executor.
-
stopRun
()[source]¶ Change the GUI when an app/script stops running.
This method enables/disables the parts of the GUI that should or should not be available when no script is being executed. It is called by the application executor when an application stops.
-
closeEvent
(event)[source]¶ Override the close event handler.
We override the default close event handler for the main window, to allow the user to cancel the exit, and to save the latest settings.
-
fullScreen
(onoff=None)[source]¶ Toggle the canvas full screen mode.
Fullscreen mode hides all the components of the main window, except for the central canvas, maximizes the main window, and removes the window decorations, thus leaving only the OpenGL canvas on the full screen. (Currently there is also still a small border remaining.)
This mode is activated by pressing the F5 key. A second F5 press will revert to normal display mode.
-
44.2. Functions defined in module gui.guimain¶
-
gui.guimain.
setAppFont
(font)[source]¶ Set the main application font.
font is either a QFont or a string resulting from the QFont.toString() method
-
gui.guimain.
setAppFontFamily
(family)[source]¶ Set the main application font family to the given family.
-
gui.guimain.
setAppFontSize
(size)[source]¶ Set the main application font size to the given point size.
-
gui.guimain.
setAppearance
()[source]¶ Set all the GUI appearance elements.
Sets the GUI appearance from the current configuration values ‘gui/style’, ‘gui/font’, ‘gui/fontfamily’, ‘gui/fontsize’.
-
gui.guimain.
xwininfo
(windowid=None, name=None)[source]¶ Returns the X window info parsed as a dict.
Either the windowid or the window name has to be specified.
-
gui.guimain.
pidofxwin
(windowid)[source]¶ Returns the PID of the process that has created the window.
Remark: Not all processes store the PID information in the way it is retrieved here. In many cases (X over network) the PID can not be retrieved. However, the intent of this function is just to find a dangling pyFormex process, and should probably work on a normal desktop configuration.
-
gui.guimain.
windowExists
(windowname)[source]¶ Check if a GUI window with the given name exists.
On X-Window systems, we can use the xwininfo command to find out whether a window with the specified name exists.
-
gui.guimain.
findOldProcesses
(max=16)[source]¶ Find old pyFormex GUI processes still running.
There is a maximum to the number of processes that can be detected. 16 will suffice largely, because there is no sane reason to open that many pyFormex GUI’s on the same screen.
Returns the next available main window name, and a list of running pyFormex GUI processes, if any.