def main(): parser = optparse.OptionParser() parser.add_option('-c', '--capacity', default=0, type='int', dest='capacity', help='Maximum number of messages to hold') parser.add_option('-t', '--tcp', default='0.0.0.0', dest='tcphost', help='Where to listen for TCP traffic (host[:port])') parser.add_option('-u', '--udp', default='0.0.0.0', dest='udphost', help='Where to listen for UDP traffic (host[:port])') parser.add_option('-z', '--zmq', default='localhost:9024', dest='zmqhost', help='Where to listen for UDP traffic (host[:port])') # On a packaged OS X system, a '-psn' argument is passed which we # don't care about args = [arg for arg in sys.argv[1:] if not arg.startswith('-psn')] options, args = parser.parse_args(args) app = QtGui.QApplication(sys.argv) QCoreApplication = QtCore.QCoreApplication QCoreApplication.setApplicationName('LogView') QCoreApplication.setApplicationVersion('0.1') QCoreApplication.setOrganizationName('Vinay Sajip') QCoreApplication.setOrganizationDomain('www.red-dove.com') main = MainWindow(options) main.show() # On OS X, this call is needed to bring the application window to the # front. if sys.platform.startswith('darwin'): main.raise_() app.exec_()
def test_mousemanager(): import sys app = QtGui.QApplication(sys.argv) app.setApplicationName('MouseManager') mainwin = MainWin() mainwin.show() sys.exit(app.exec_())
def test_ovrwidget(): filename = os.path.join(GSDVIEWROOT, 'gsdview', 'plugins', 'worldmap', 'images', 'world_4320x2160.jpg') dataset = gdal.Open(filename) band = dataset.GetRasterBand(1) if True and band.GetOverviewCount() == 0: dataset.BuildOverviews('average', [2, 4, 8], gdal.TermProgress) app = QtGui.QApplication(sys.argv) w = OverviewWidget(band) w.show() def callback(): args = w.optionlist() levels = map(str, w.levels()) parts = ['gdaladdo'] parts.extend(args) parts.append(os.path.basename(filename)) parts.extend(levels) print ' '.join(parts) w.overviewComputationRequest.connect(callback) sys.exit(app.exec_())
def test_stretchingdialog(floatmode=False): app = QtGui.QApplication(sys.argv) d = StretchDialog() #state = d.stretchwidget.state() d.stretchwidget.floatmode = floatmode d.show() app.exec_()
def test_generalpreferencespage(): app = QtGui.QApplication(sys.argv) d = QtGui.QDialog() layout = QtGui.QVBoxLayout() layout.addWidget(GeneralPreferencesPage()) d.setLayout(layout) d.show() app.exec_()
def test_fileentrywidget(): app = QtGui.QApplication(sys.argv) d = QtGui.QDialog() layout = QtGui.QVBoxLayout() layout.addWidget(FileEntryWidget()) d.setLayout(layout) d.show() app.exec_()
def test_gdalinfowidget(): app = QtGui.QApplication(sys.argv) dialog = QtGui.QDialog() layout = QtGui.QVBoxLayout() layout.addWidget(GDALInfoWidget()) dialog.setLayout(layout) dialog.resize(500, 400) dialog.show() app.exec_()
def test_gdalpreferencespage(): app = QtGui.QApplication(sys.argv) dialog = QtGui.QDialog() layout = QtGui.QVBoxLayout() layout.addWidget(GDALPreferencesPage()) dialog.setLayout(layout) dialog.resize(500, 400) dialog.show() app.exec_()
def test_ovrdialog(): filename = os.path.join(GSDVIEWROOT, 'gsdview', 'plugins', 'worldmap', 'images', 'world_4320x2160.jpg') dataset = gdal.Open(filename) app = QtGui.QApplication(sys.argv) d = OverviewDialog() d.setItem(dataset) d.show() sys.exit(app.exec_())
def main(): app = QtGui.QApplication(sys.argv) QtCore.QThread.currentThread().setObjectName("MainThread") # QtGui.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps) # noinspection PyCallByClass,PyTypeChecker QtGui.QApplication.setStyle(application_style) QtGui.QApplication.setApplicationName(config.APPLICATION_NAME) QtGui.QApplication.setApplicationVersion(__version__) # noinspection PyUnusedLocal main_window = MainWindow() sys.exit(app.exec_())
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 = QtGui.QApplication(argv) app.setApplicationName('GraphicsDrawApp') w = GraphicsDrawApp() w.show() sys.exit(app.exec_())
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 = QtGui.QApplication(sys.argv) d = GSDViewExceptionDialog() #d = ExceptionDialog() d.show() app.exec_() print 'done.'
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 = QtGui.QApplication(argv) app.setApplicationName('VectorGraphicsApp') w = VectorGraphicsApp() w.show() for filename in argv[1:]: w.openvector(filename) w._autocolor() sys.exit(app.exec_())
areas = [] for geom in self.geoms: shape = geom.to_shapely(scaling = popupcad.csg_processing_scaling) areas.append(abs(shape.area)) goodgeoms = [] badgeoms = [] for geom in self.geoms: shape = geom.to_shapely(scaling = popupcad.csg_processing_scaling) if abs(shape.area) < max(areas) * area_ratio: badgeoms.append(geom) else: goodgeoms.append(geom) self.geoms = goodgeoms self.badgeoms = badgeoms @staticmethod def buildloops(geoms): loops = [] for geom in geoms: loops.append(geom.exteriorpoints()) loops.extend(geom.interiorpoints()) return loops if __name__ == '__main__': import sys app = qg.QApplication(sys.argv) a = Assembly.open() a.convert(scalefactor=1., bufferval=None) sys.exit(app.exec_())
else: self.setCurrentBlockState(in_state) length = len(text) - start + add # Apply formatting self.setFormat(start, length, style) # Look for the next match start = delimiter.indexIn(text, start + length) # Return True if still inside a multi-line string, False otherwise if self.currentBlockState() == in_state: return True else: return False if __name__ == "__main__": import qt.QtCore as qc import qt.QtGui as qg import syntax app = qg.QApplication([]) editor = qg.QPlainTextEdit() syntax.PythonHighlighter(editor.document()) editor.show() # Load syntax.py into the editor for demo purposes infile = open('syntax.py', 'r') editor.setPlainText(infile.read()) app.exec_()
action.setCheckable(kwargs['is_checkable']) except KeyError: pass try: action.setChecked(kwargs['is_checked']) except KeyError: pass try: parent_trigger_method_name = kwargs['triggered'] if hasattr(parent_trigger_method_name, '__call__'): parent_trigger_method = parent_trigger_method_name else: parent_trigger_method = getattr(parent, parent_trigger_method_name) action.triggered.connect(parent_trigger_method) except (KeyError, AttributeError): pass return action def set_parent(self, parent): for item, value in self.actions.items(): value.setParent(parent) if __name__ == '__main__': app = qg.QApplication([sys.argv[0]]) m.build() # sys.exit(app.exec_())
#~ 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 = QtGui.QApplication(sys.argv) mainwin = Qt4Shell(debug=True) mainwin.show() sys.exit(app.exec_())
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' options, args = cmdline_ui() # logging.basicConfig(level=logging.DEBUG, logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') logger = logging.getLogger('gsdview') logger.setLevel(logging.DEBUG) # @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 qt import QtGui logging.debug('Qt4 import: %d.%06ds' % timer.update()) import sys from .info import name as NAME from .info import version as VERSION from .utils import getresource app = QtGui.QApplication(sys.argv) app.setApplicationName(NAME) app.setApplicationVersion(VERSION) pngfile = getresource(os.path.join('images', 'splash.png'), __name__) pixmap = QtGui.QPixmap(pngfile) splash = QtGui.QSplashScreen(pixmap) splash.show() app.processEvents() splash_loghandler = SplashLogHandler(splash, app) splash_loghandler.setFormatter(logging.Formatter('%(message)s')) logger.addHandler(splash_loghandler) logger.debug('Splash screen setup completed') logging.debug('splash screen setup: %d.%06ds' % timer.update()) ### modules loading ####################################################### preload(MODULES, app) ### GUI ################################################################### logger.info('Build GUI ...') from .app import GSDView mainwin = GSDView() # @TODO: pass plugins_path, loglevel?? mainwin.show() logger.info('GUI setup completed') logging.debug('GUI setup: %d.%06ds' % timer.update()) ### close splash and run app ############################################## logger.removeHandler(splash_loghandler) splash.finish(mainwin) app.processEvents() logger.info('Install the exception hook') sys.excepthook = mainwin.excepthook # @TODO: check logger.info('Enter main event loop') # @COMPATIBILITY: this will raise the window on Mac OS X mainwin.raise_() sys.exit(app.exec_())
def test_histogram_config(): app = QtGui.QApplication(sys.argv) dialog = HistogramConfigDialog() dialog.show() sys.exit(app.exec_())
def test_rasterbanddialog(band): app = QtGui.QApplication(sys.argv) dialog = BandInfoDialog(band) dialog.show() sys.exit(app.exec_())
def test_datasetdialog(dataset): app = QtGui.QApplication(sys.argv) dialog = DatasetInfoDialog(dataset) dialog.show() sys.exit(app.exec_())
def test_mdimainwin(): import sys app = QtGui.QApplication(sys.argv) mainwindow = TestMdiMainWindow() mainwindow.show() sys.exit(app.exec_())
""" This script runs a test for the code editor component. """ import os, sys from qt import QtGui, QtCore Qt = QtCore.Qt ## Go up one directory and then import the codeeditor package os.chdir('..') sys.path.insert(0, '.') from codeeditor import CodeEditor if __name__ == '__main__': app = QtGui.QApplication([]) class TestEditor(CodeEditor): def keyPressEvent(self, event): key = event.key() if key == Qt.Key_F1: self.autocompleteShow() return elif key == Qt.Key_F2: self.autocompleteCancel() return elif key == Qt.Key_F3: self.calltipShow(0, 'test(foo, bar)') return elif key == Qt.Key_Backtab: #Shift + Tab self.dedentSelection()
def test_preferencesdialog(): app = QtGui.QApplication(sys.argv) d = PreferencesDialog() d.show() app.exec_()
def test_aboutdialog(): app = QtGui.QApplication(sys.argv) d = AboutDialog() d.show() app.exec_()