def show_basic_window( widget_class=None, window_class=None, size=None, position=(20, 20), autodestruct=None, toolbar=False, **kwargs ): """Create a custom widget and/or window and show it immediately. Arguments: * widget_class=None: the class deriving from GalryWidget. * window_class=None: the window class, deriving from `QMainWindow`. * size=None: the size of the window as a tuple (width, height). * position=(100, 100): the initial position of the window on the screen, in pixels (x, y). * autodestruct=None: if not None, it is the time, in seconds, before the window closes itself. * **kwargs: keyword arguments with the companion classes and other parameters that are passed to `create_custom_widget`. """ # default widget class if widget_class is None: widget_class = create_custom_widget(**kwargs) # defaut window class if window_class is None: window_class = create_basic_window( widget_class, size=size, position=position, autodestruct=autodestruct, toolbar=toolbar ) # create and show window return show_window(window_class)
def main(): if len(sys.argv) > 1: filename = sys.argv[1] else: filename = None window = show_window(KwikSkope, filename=filename) return window
def show_basic_window(widget_class=None, window_class=None, size=None, position=(20, 20), autodestruct=None, toolbar=False, **kwargs): """Create a custom widget and/or window and show it immediately. Arguments: * widget_class=None: the class deriving from GalryWidget. * window_class=None: the window class, deriving from `QMainWindow`. * size=None: the size of the window as a tuple (width, height). * position=(100, 100): the initial position of the window on the screen, in pixels (x, y). * autodestruct=None: if not None, it is the time, in seconds, before the window closes itself. * **kwargs: keyword arguments with the companion classes and other parameters that are passed to `create_custom_widget`. """ # default widget class if widget_class is None: widget_class = create_custom_widget(**kwargs) # defaut window class if window_class is None: window_class = create_basic_window(widget_class, size=size, position=position, autodestruct=autodestruct, toolbar=toolbar, ) # create and show window return show_window(window_class)
def main(): if len(sys.argv) > 1: filename = sys.argv[1] else: filename = None window = show_window(MainWindow, filename=filename) return window
def main(): shank = None if len(sys.argv) > 1: filename = sys.argv[1] if len(sys.argv) > 2: shank = int(sys.argv[2]) else: filename = None window = show_window(MainWindow, filename=filename, shank=shank) return window
def show_view(view_class, **kwargs): class TestWindow(QtGui.QMainWindow): def __init__(self): super(TestWindow, self).__init__() self.setFocusPolicy(QtCore.Qt.WheelFocus) self.setMouseTracking(True) self.setWindowTitle("View") self.view = view_class(self, **kwargs) self.setCentralWidget(self.view) self.move(100, 100) self.show() window = show_window(TestWindow) return window
def show_view(view_class, **kwargs): operators = kwargs.pop('operators', None) # Display a view. class TestWindow(QtGui.QMainWindow): operatorStarted = QtCore.pyqtSignal(int) def __init__(self): super(TestWindow, self).__init__() self.setFocusPolicy(QtCore.Qt.WheelFocus) self.setMouseTracking(True) self.setWindowTitle("KlustaViewa") self.view = view_class(self, getfocus=False) self.view.set_data(**kwargs) self.setCentralWidget(self.view) self.move(100, 100) self.show() # Start "operator" asynchronously in the main thread. if operators: self.operator_list = operators self.operatorStarted.connect(self.operator) self._thread = threading.Thread(target=self._run_operator) self._thread.start() def _run_operator(self): for i in xrange(len(self.operator_list)): # Call asynchronously operation #i, after a given delay. if type(self.operator_list[i]) == tuple: dt = self.operator_list[i][1] else: # Default delay. dt = USERPREF['test_operator_delay'] or .1 time.sleep(dt) self.operatorStarted.emit(i) def operator(self, i): # Execute operation #i. if type(self.operator_list[i]) == tuple: fun = self.operator_list[i][0] else: fun = self.operator_list[i] fun(self) def keyPressEvent(self, e): super(TestWindow, self).keyPressEvent(e) self.view.keyPressEvent(e) if e.key() == QtCore.Qt.Key_Q: self.close() def keyReleaseEvent(self, e): super(TestWindow, self).keyReleaseEvent(e) self.view.keyReleaseEvent(e) def closeEvent(self, e): if operators: self._thread.join() return super(TestWindow, self).closeEvent(e) window = show_window(TestWindow) return window
def DISABLEDtest_mainwindow(): show_window(MainWindow, dolog=False)