Esempio n. 1
0
def test_mousemanager():
    import sys
    app = QtWidgets.QApplication(sys.argv)
    app.setApplicationName('MouseManager')
    mainwin = MainWin()
    mainwin.show()
    sys.exit(app.exec_())
Esempio n. 2
0
def test_generalpreferencespage():
    app = QtWidgets.QApplication(sys.argv)
    d = QtWidgets.QDialog()
    layout = QtWidgets.QVBoxLayout()
    layout.addWidget(GeneralPreferencesPage())
    d.setLayout(layout)
    d.show()
    app.exec_()
Esempio n. 3
0
def test_fileentrywidget():
    app = QtWidgets.QApplication(sys.argv)
    d = QtWidgets.QDialog()
    layout = QtWidgets.QVBoxLayout()
    layout.addWidget(FileEntryWidget())
    d.setLayout(layout)
    d.show()
    app.exec_()
Esempio n. 4
0
def main(*argv):
    # @NOTE: basic config doesn't work since sip use it before this line
    #logging.basicConfig(level=logging.DEBUG,
    #                    format='%(levelname): %(message)s')
    logging.getLogger().setLevel(logging.DEBUG)

    if not argv:
        argv = sys.argv
    else:
        argv = list(argv)

    app = QtWidgets.QApplication(argv)
    app.setApplicationName('GraphicsDrawApp')
    w = GraphicsDrawApp()
    w.show()

    sys.exit(app.exec_())
Esempio n. 5
0
def test_exceptiondialog():
    def f(depth, verbose=False):
        if verbose:
            print(1 / depth)
        else:
            1 / depth
        return f(depth - 1, verbose)

    try:
        f(4)
    except Exception:
        app = QtWidgets.QApplication(sys.argv)
        d = GSDViewExceptionDialog()
        #d = ExceptionDialog()
        d.show()
        app.exec_()
    print('done.')
Esempio n. 6
0
def test_mdimainwin():
    import sys
    app = QtWidgets.QApplication(sys.argv)
    mainwindow = TestMdiMainWindow()
    mainwindow.show()
    sys.exit(app.exec_())
Esempio n. 7
0
def main():
    # @IMPORTANT: force numeric locale to 'C' in order to avoid problems
    #             with GDAL and PPROJ4
    # @SEEALSO: http://trac.osgeo.org/gdal/wiki/FAQMiscellaneous#DoesGDALworkindifferentinternationalnumericlocales
    import os
    os.environ['LC_NUMERIC'] = 'C'

    args = parse_args()

    if args.log_level != 'NOTSET':
        loglevel = logging.getLevelName(args.log_level)
    else:
        loglevel = logging.INFO

    logging.basicConfig(
        level=loglevel,
        #format='%(levelname)s: %(message)s')
        format='%(asctime)s %(name)s %(levelname)s: %(message)s')

    # set the logging level explicitly on gsdview logger
    #logging.getLogger().setLevel(loglevel)
    logging.getLogger('gsdview').setLevel(loglevel)

    # PyQt loggers
    logging.getLogger('PyQt5.uic').setLevel(logging.WARNING)

    log = logging.getLogger(__name__)
    log.debug('log level set to %s', logging.getLevelName(log.level))

    # @TODO:
    # * config logging using options.configfile, USER_CFG, SYS_CFG
    # * if options.debug: set rootlogger.level = logging.DEBUG
    # * maybe set loglevelfor other loggers

    timer = Timer()

    # splash screen #########################################################
    from qtsix import QtWidgets, QtGui
    log.debug('Qt import: %d.%06ds', *timer.update())

    import sys
    from gsdview.info import name as NAME
    from gsdview.info import version as VERSION
    from gsdview.utils import getresource

    app = QtWidgets.QApplication(sys.argv)
    app.setApplicationName(NAME)
    app.setApplicationVersion(VERSION)

    pngfile = getresource(os.path.join('images', 'splash.png'), __name__)
    pixmap = QtGui.QPixmap(pngfile)
    splash = QtWidgets.QSplashScreen(pixmap)
    splash.show()
    app.processEvents()

    splash_loghandler = SplashLogHandler(splash, app)
    splash_loghandler.setFormatter(logging.Formatter('%(message)s'))

    log.addHandler(splash_loghandler)

    log.info('Splash screen setup completed')
    log.debug('splash screen setup: %d.%06ds', *timer.update())

    # modules loading #######################################################
    preload(MODULES, app)

    # GUI ###################################################################
    log.info('Build GUI ...')

    from gsdview.app import GSDView

    # @TODO: pass plugins_path??
    mainwin = GSDView(loglevel=args.log_level)
    mainwin.show()
    log.info('GUI setup completed')
    log.debug('GUI setup: %d.%06ds', *timer.update())

    # close splash and run app ##############################################
    log.removeHandler(splash_loghandler)
    splash.finish(mainwin)
    app.processEvents()

    log.info('Install the exception hook')
    sys.excepthook = mainwin.excepthook     # @TODO: check

    log.info('Enter main event loop')

    # @COMPATIBILITY: this will raise the window on Mac OS X
    mainwin.raise_()

    sys.exit(app.exec_())
Esempio n. 8
0
            #~ return
        #~ self.execute()

    # @TODO: complete
    #~ def on_populate_popup(self, widget, menu, data=None):
        #~ # separator
        #~ item = gtk.SeparatorMenuItem()
        #~ item.show()
        #~ menu.append(item)

        #~ # Clear history
        #~ item = gtk.ImageMenuItem(gtk.STOCK_CLEAR)
        #~ item.set_name('clear_history')
        #~ item.activate.connect(self.on_clear_history)
        #~ item.activate.connect(self.on_clear_entry)
        #~ item.show()
        #~ menu.append(item)

    #~ def on_clear_history(self):
        #~ self.cmdbox.clear()

    #~ def on_clear_entry(self):
        #~ self.cmdbox.clearEdirText()

if __name__ == '__main__':
    import sys
    app = QtWidgets.QApplication(sys.argv)
    mainwin = QtShell(debug=True)
    mainwin.show()
    sys.exit(app.exec_())
Esempio n. 9
0
class StretchWidgetTestCase(unittest.TestCase):
    app = QtWidgets.QApplication(sys.argv)
    FLOATMODE = False

    def setUp(self):
        self.stretch = StretchWidget(floatmode=self.FLOATMODE)
        self.stretch.setLow(10)

    def test_defaults(self):
        self.assertEqual(self.stretch.low(), 10)
        self.assertEqual(self.stretch.high(), 100)
        self.assertEqual(self.stretch.minimum(), 0)
        self.assertEqual(self.stretch.maximum(), 255)

    def test_floatmode_change(self):
        low = self.stretch.low()
        high = self.stretch.high()
        minimum = self.stretch.minimum()
        maximum = self.stretch.maximum()

        self.stretch.floatmode = not self.stretch.floatmode
        if not self.stretch.floatmode:
            low = int(low)
            high = int(high)

        self.assertAlmostEqual(self.stretch.low(), low)
        self.assertAlmostEqual(self.stretch.high(), high)
        self.assertAlmostEqual(self.stretch.minimum(), minimum)
        self.assertAlmostEqual(self.stretch.maximum(), maximum)

    def test_floatmode_change_and_back(self):
        low = self.stretch.low()
        high = self.stretch.high()
        minimum = self.stretch.minimum()
        maximum = self.stretch.maximum()

        self.stretch.floatmode = not self.stretch.floatmode
        if not self.stretch.floatmode:
            low = int(low)
            high = int(high)

        self.assertAlmostEqual(self.stretch.low(), low)
        self.assertAlmostEqual(self.stretch.high(), high)
        self.assertAlmostEqual(self.stretch.minimum(), minimum)
        self.assertAlmostEqual(self.stretch.maximum(), maximum)

        self.stretch.floatmode = not self.stretch.floatmode

        self.assertAlmostEqual(self.stretch.low(), low)
        self.assertAlmostEqual(self.stretch.high(), high)
        self.assertAlmostEqual(self.stretch.minimum(), minimum)
        self.assertAlmostEqual(self.stretch.maximum(), maximum)

    def test_decrease_minimum(self):
        low, high = self.stretch.values()
        minimum = self.stretch.minimum()
        delta = 1000 * max(abs(minimum), 1)
        self.stretch.setMinimum(minimum - delta)
        self.assertEqual(low, self.stretch.low())
        self.assertEqual(high, self.stretch.high())

    def test_increase_minimum(self):
        low, high = self.stretch.values()
        minimum = self.stretch.minimum()
        delta = low - minimum
        self.stretch.setMinimum(minimum + delta / 2)
        self.assertEqual(low, self.stretch.low())
        self.assertEqual(high, self.stretch.high())

    def test_increase_minimum_above_low(self):
        low, high = self.stretch.values()
        minimum = 0.5 * (low + high)
        self.assertGreater(minimum, low)
        self.assertLess(minimum, high)
        self.stretch.setMinimum(minimum)
        self.assertEqual(self.stretch.low(), minimum)
        self.assertEqual(high, self.stretch.high())

    def test_increase_minimum_above_high(self):
        low, high = self.stretch.values()
        delta = min(abs(low), abs(high)) / 2
        minimum = high + delta
        self.assertGreater(minimum, high)
        self.assertLess(minimum, self.stretch.maximum())
        self.stretch.setMinimum(minimum)
        self.assertAlmostEqual(self.stretch.low(), minimum)
        self.assertAlmostEqual(self.stretch.high(), minimum)
        #self.assertGreaterEqual(high, minimum)

    def test_increase_minimum_above_maximum(self):
        delta = max(abs(self.stretch.minimum()), abs(self.stretch.maximum()))
        minimum = self.stretch.maximum() + delta
        self.assertRaises(ValueError, self.stretch.setMinimum, minimum)

    def test_decrease_maximum_below_minimum(self):
        delta = max(abs(self.stretch.minimum()), abs(self.stretch.maximum()))
        maximum = self.stretch.minimum() - delta
        self.assertRaises(ValueError, self.stretch.setMaximum, maximum)

    def test_decrease_maximum_below_low(self):
        low, high = self.stretch.values()
        delta = min(abs(low), abs(high)) / 2
        maximum = low - delta
        self.assertLess(maximum, low)
        self.assertGreater(maximum, self.stretch.minimum())
        self.stretch.setMaximum(maximum)
        self.assertEqual(self.stretch.low(), maximum)
        self.assertEqual(self.stretch.high(), maximum)
        #self.assertLessEqual(low, maximum)

    def test_decrease_maximum_below_high(self):
        low, high = self.stretch.values()
        maximum = 0.5 * (low + high)
        self.assertGreater(maximum, low)
        self.assertLess(maximum, high)
        self.stretch.setMaximum(maximum)
        self.assertEqual(low, self.stretch.low())
        self.assertEqual(self.stretch.high(), maximum)

    def test_decrease_maximum(self):
        low, high = self.stretch.values()
        maximum = self.stretch.maximum()
        delta = maximum - high
        self.stretch.setMaximum(maximum + delta / 2)
        self.assertEqual(low, self.stretch.low())
        self.assertEqual(high, self.stretch.high())

    def test_increase_maximum(self):
        low, high = self.stretch.values()
        maximum = self.stretch.maximum()
        delta = 1000 * max(abs(maximum), 1)
        self.stretch.setMaximum(maximum + delta)
        self.assertEqual(low, self.stretch.low())
        self.assertEqual(high, self.stretch.high())

    # broken tests
    if False:

        def test_ui_decrease_minimum(self):
            low, high = self.stretch.values()
            minimum = self.stretch.minimum()
            delta = 1000 * max(abs(minimum), 1)
            value = minimum - delta
            QTest.keyClicks(self.stretch.minSpinBox, str(value))
            self.assertEqual(self.stretch.minimum(), value)
            self.assertEqual(low, self.stretch.low())
            self.assertEqual(high, self.stretch.high())

        def test_ui_increase_minimum(self):
            low, high = self.stretch.values()
            minimum = self.stretch.minimum()
            delta = low - minimum
            value = minimum + delta / 2
            QTest.keyClicks(self.stretch.minSpinBox, str(value))
            self.assertEqual(self.stretch.minimum(), value)
            self.assertEqual(low, self.stretch.low())
            self.assertEqual(high, self.stretch.high())

        def test_ui_increase_minimum_above_low(self):
            low, high = self.stretch.values()
            minimum = 0.5 * (low + high)
            self.assertGreater(minimum, low)
            self.assertLess(minimum, high)
            QTest.keyClicks(self.stretch.minSpinBox, str(minimum))
            self.assertEqual(self.stretch.minimum(), minimum)
            self.assertEqual(self.stretch.low(), minimum)
            self.assertEqual(high, self.stretch.high())

        def test_ui_increase_minimum_above_high(self):
            low, high = self.stretch.values()
            delta = min(abs(low), abs(high)) / 2
            minimum = high + delta
            self.assertGreater(minimum, high)
            self.assertLess(minimum, self.stretch.maximum())
            QTest.keyClicks(self.stretch.minSpinBox, str(minimum))
            self.assertEqual(self.stretch.minimum(), minimum)
            self.assertEqual(self.stretch.low(), minimum)
            self.assertEqual(self.stretch.high(), minimum)
            #self.assertGreaterEqual(high, minimum)

        @unittest.skip('incomplete')
        def test_ui_increase_minimum_above_maximum(self):
            delta = max(abs(self.stretch.minimum()),
                        abs(self.stretch.maximum()))
            minimum = self.stretch.maximum() + delta
            QTest.keyClicks(self.stretch.minSpinBox, str(minimum))
            self.assertEqual(self.stretch.minimum(), minimum)
            #self.assertRaises(ValueError, self.stretch.setMinimum, minimum)

        @unittest.skip('incomplete')
        def test_ui_decrease_maximum_below_minimum(self):
            delta = max(abs(self.stretch.minimum()),
                        abs(self.stretch.maximum()))
            maximum = self.stretch.minimum() - delta
            QTest.keyClicks(self.stretch.maxSpinBox, str(maximum))
            self.assertEqual(self.stretch.maximum(), maximum)
            #self.assertRaises(ValueError, self.stretch.setMaximum, maximum)

        def test_ui_decrease_maximum_below_low(self):
            low, high = self.stretch.values()
            delta = min(abs(low), abs(high)) / 2
            maximum = low - delta
            self.assertLess(maximum, low)
            self.assertGreater(maximum, self.stretch.minimum())
            QTest.keyClicks(self.stretch.maxSpinBox, str(maximum))
            self.assertEqual(self.stretch.maximum(), maximum)
            self.assertEqual(self.stretch.low(), maximum)
            self.assertEqual(self.stretch.high(), maximum)
            #self.assertLessEqual(low, maximum)

        def test_ui_decrease_maximum_below_high(self):
            low, high = self.stretch.values()
            maximum = 0.5 * (low + high)
            self.assertGreater(maximum, low)
            self.assertLess(maximum, high)
            QTest.keyClicks(self.stretch.maxSpinBox, str(maximum))
            self.assertEqual(self.stretch.maximum(), maximum)
            self.assertEqual(low, self.stretch.low())
            self.assertEqual(self.stretch.high(), maximum)

        def test_ui_decrease_maximum(self):
            low, high = self.stretch.values()
            maximum = self.stretch.maximum()
            delta = maximum - high
            value = maximum + delta / 2
            QTest.keyClicks(self.stretch.maxSpinBox, str(value))
            self.assertEqual(self.stretch.maximum(), value)
            self.assertEqual(low, self.stretch.low())
            self.assertEqual(high, self.stretch.high())

        def test_ui_increase_maximum(self):
            low, high = self.stretch.values()
            maximum = self.stretch.maximum()
            delta = 1000 * max(abs(maximum), 1)
            value = maximum + delta
            QTest.keyClicks(self.stretch.maxSpinBox, str(value))
            self.assertEqual(self.stretch.maximum(), value)
            self.assertEqual(low, self.stretch.low())
            self.assertEqual(high, self.stretch.high())
Esempio n. 10
0
def _test_stretchingdialog(floatmode=False):
    app = QtWidgets.QApplication(sys.argv)
    d = StretchDialog(floatmode=floatmode)
    #state = d.stretchwidget.state()
    d.show()
    app.exec_()
Esempio n. 11
0
def test_preferencesdialog():
    app = QtWidgets.QApplication(sys.argv)
    d = PreferencesDialog()
    d.show()
    app.exec_()
Esempio n. 12
0
def test_aboutdialog():
    app = QtWidgets.QApplication(sys.argv)
    d = AboutDialog()
    d.show()
    app.exec_()