Beispiel #1
0
    def __init__(self, jpath_or_analyser, testsuites, testsuite_paths):
        self.win = ThemedTk(title='json explorer', esc_closes=True,
                geometry=(-200, -200))

        if sys.platform == 'win32':
            self.win.wm_iconbitmap(bitmap = get_root_path('res', 'TPH_DNA.ico'))

        self.win.columnconfigure(0, weight=1)
        self.win.columnconfigure(1, weight=0)
        self.win.rowconfigure(0, weight=0)
        self.win.rowconfigure(1, weight=0)
        self.win.rowconfigure(2, weight=4)

        if isinstance(jpath_or_analyser, Analyser):
            self.analyser = jpath_or_analyser
            name = os.path.basename(self.analyser.fastq.fname)
        else:
            try:

                data = json.load(file(jpath_or_analyser))
                update_testsuites(testsuites, data['info']['testsuites'], testsuite_paths)

                self.analyser = Analyser()
                self.analyser.decode(testsuites, data)
                self.analyser.update_testsuites()
            except Exception, e:
                exc_info = sys.exc_info()
                self.win.destroy()
                raise exc_info[1], None, exc_info[2]
            name = os.path.basename(jpath_or_analyser)
Beispiel #2
0
    def __init__(self, title=None, esc_closes=False, geometry=None):
        ''' :param esc_closes: whether hitting the ``<Escape>`` key should close
                the window (via overridable :py:meth:`close` callback)

            :param geometry: tuple ``(width, height)`` where both parameters can
                be either pixels or fractions (value between 0-1) or difference
                from total screen dimension (value below 0) '''

        tk.Tk.__init__(self)
        if title:
            title = ' -- ' + title
        else:
            title = ''
        self.wm_title('KvarQ ' + str(VERSION) + title)

        if sys.platform == 'win32':
            self.wm_iconbitmap(bitmap = get_root_path('res', 'TPH_DNA.ico'))

        self.monospace = tkFont.Font(self, family='Courier New', weight=tkFont.BOLD)
        self.boldfont = tkFont.Font(self, weight='bold')

        if esc_closes:
            self.bind('<Escape>', lambda x: self.close())

        if geometry:
            sw = self.winfo_screenwidth()
            sh = self.winfo_screenheight()

            w, h = geometry
            if w<0: w = sw + w
            elif w<1: w = int(sw * w)
            if h<0: h = sh + h
            elif h<1: h = int(sh * h)

            w = max(200, min(w, sw - 100))
            h = max(200, min(h, sh - 200))
            self.geometry('%dx%d+%d+%d'%(w,h,50,(sh-h)/2))

        self.focus_force()