-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloadscreen.py
54 lines (42 loc) · 1.81 KB
/
loadscreen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright (c) 2020 PHYTEC Messtechnik GmbH
# SPDX-License-Identifier: Apache-2.0
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class LoadScreen(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title='Load Celebrity Face Match Demo')
self.set_default_size(640, 480)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_border_width(10)
self.label = Gtk.Label()
self.progress_bar = Gtk.ProgressBar()
self.textview = Gtk.TextView()
self.label.set_markup(
'<span font="20" font_weight="bold"> Loading Demo ... (can take up to two minutes) </span>'
)
self.progress_bar.set_text('ProgressBar')
self.progress_bar.set_fraction(0.0)
self.textview.set_editable(True)
self.textview.set_cursor_visible(True)
self.textview.set_justification(Gtk.Justification.LEFT)
self.textview.set_wrap_mode(Gtk.WrapMode.WORD)
self.textview.set_vexpand(True)
self.textview.set_monospace(True)
self.textbuffer = self.textview.get_buffer()
scrollwindow = Gtk.ScrolledWindow()
scrollwindow.set_hexpand(True)
scrollwindow.set_vexpand(True)
scrollwindow.add(self.textview)
hbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=30)
hbox.pack_start(self.label, False, False, 0)
hbox.pack_start(self.progress_bar, False, False, 0)
hbox.pack_start(scrollwindow, True, True, 0)
self.add(hbox)
self.show_all()
def append_text(self, text, fraction):
cur_iter = self.textbuffer.get_end_iter()
self.textbuffer.insert(cur_iter, text)
cur_iter = self.textbuffer.get_end_iter()
self.textbuffer.insert(cur_iter, '\n')
self.progress_bar.set_fraction(fraction)