Exemplo n.º 1
0
def main():
    try:
        app = QApplication(sys.argv)
        #app.setStyle('cleanlooks')
        app.setStyleSheet(qdarkstyle.load_stylesheet())
        db = Database('sample.db')

        icon = QIcon('app.ico')
        app.setWindowIcon(icon)

    #   set the default font for the app
        app.setFont(MEDIUM_FONT)
        app.setStyle(BUTTON_STYLE)

        main_view = MainView()
        main_view.showMaximized()
 
        main_view.show()
        app.exec_()

    #   clean up and exit code
        for model in main_view.models:
            model.submitAll() # commit all pending changes to all models
        db.close()
        app.quit()
        sys.exit(0)
        #os._exit(0)
    except SystemExit:
        print("Closing Window...")
    except Exception as e:
        print(str(e))
Exemplo n.º 2
0
    def __init__(self, parent=None):
        super(SplitterWidget, self).__init__(parent)
        self.setWindowTitle("Splitter")

        font = QFont(self.tr("黑体"), 12)
        QApplication.setFont(font)

        mainSplitter = QSplitter(Qt.Horizontal, self)

        leftText = QTextEdit(self.tr("左窗口"), mainSplitter)
        leftText.setAlignment(Qt.AlignCenter)

        rightSplitter = QSplitter(Qt.Vertical, mainSplitter)
        rightSplitter.setOpaqueResize(False)

        upText = QTextEdit(self.tr("上窗口"), rightSplitter)
        upText.setAlignment(Qt.AlignCenter)

        bottomText = QTextEdit(self.tr("下窗口"), rightSplitter)
        bottomText.setAlignment(Qt.AlignCenter)

        mainSplitter.setStretchFactor(1, 1)
        mainSplitter.setWindowTitle(self.tr("分割窗口"))

        self.setCentralWidget(mainSplitter)
Exemplo n.º 3
0
def LevelFigure(levels, show=True, **kwargs):
    figtype = kwargs.pop('figtype', 'bar')
    from PySide.QtGui import QApplication, QFont
    app = QApplication.instance()
    if not app:
        app = QApplication(sys.argv)
    app.setFont(QFont('Linux Libertine'))
    size = kwargs.pop('size', (1200, 600))
    if figtype == 'bar':
        opts = PlotOptions.forLevelBars()
    elif figtype == 'line':
        opts = PlotOptions.forPower()
    else:
        raise RuntimeError('figtype should be either line or bar')
    opts.ylim = kwargs.pop('ylim', (0, 100))
    opts.ylabel = kwargs.pop('ylabel', 'LAeq [dB(A)]')
    opts.xlabel = kwargs.pop('xlabel', None)
    opts.legend = kwargs.pop('legend', [level.name for level in levels])
    opts.legendpos = kwargs.pop('legendpos', None)
    opts.title = kwargs.pop('title', None)

    def Plotter(ptas, pto):
        fig = FigureDialog(None, None, pto, figtype)
        for pta in ptas:
            fig.fig.add(pta)
        return fig

    fig = Plotter(levels, opts)
    if show:
        fig.show()
    fig.resize(*size)
    if show:
        app.exec_()
    return fig
Exemplo n.º 4
0
from sys import argv, exit
from PySide.QtGui import QApplication, QFont, QFontMetrics, QX11Info
from mainwindow import MainWindow

app = QApplication(argv)
font = QFont(QApplication.font())
font.setPointSize(9)
QApplication.setFont(font)
w = MainWindow()
metrics = QFontMetrics(font)
w.resize(metrics.width('M') * 80, metrics.height() * 24)
w.show()
exit(app.exec_())
Exemplo n.º 5
0
    if WEARECODING:
        try:
          os.remove('log.txt')
        except: 
          pass
        
    if not DEBUG:
       # Redirect `sys.stderr` and `sys.stdout` to a file 
       # when building for release.
       sys.stderr = sys.stdout = open('log.txt', 'a')
    f = sys.stdout
    class F():
        def write(self, data):
            if data.strip():
                # Only attach a timestamp to non whitespace prints.
                data = '{0} {1}'.format(dt.utcnow().strftime('%Y-%m-%d %H:%M:%S'), data)
            f.write(data)
            f.flush()
    sys.stderr = sys.stdout = F()
    
    app=QApplication.instance() # checks if QApplication already exists 
    if not app: # create QApplication if it doesnt exist 
        app = QApplication(sys.argv)

    window = SyncWindow()
    font = QFont(View.fontFamily, 12, 50, False)
    
    app.setFont(font)
    window.show()
    sys.exit(app.exec_())
Exemplo n.º 6
0
 def fontchanged(self, font):
     QApplication.setFont(font)
Exemplo n.º 7
0
            os.remove("log.txt")
        except:
            pass

    if not DEBUG:
        # Redirect `sys.stderr` and `sys.stdout` to a file
        # when building for release.
        sys.stderr = sys.stdout = open("log.txt", "a")
    f = sys.stdout

    class F:
        def write(self, data):
            if data.strip():
                # Only attach a timestamp to non whitespace prints.
                data = "{0} {1}".format(dt.utcnow().strftime("%Y-%m-%d %H:%M:%S"), data)
            f.write(data)
            f.flush()

    sys.stderr = sys.stdout = F()

    app = QApplication.instance()  # checks if QApplication already exists
    if not app:  # create QApplication if it doesnt exist
        app = QApplication(sys.argv)

    window = SyncWindow()
    font = QFont(View.fontFamily, 12, 50, False)

    app.setFont(font)
    window.show()
    sys.exit(app.exec_())