-
Notifications
You must be signed in to change notification settings - Fork 3
/
processingbar.py
67 lines (52 loc) · 2.24 KB
/
processingbar.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
55
56
57
58
59
60
61
62
63
64
65
from kivy.properties import ObjectProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from properties import DefaultProperties, TransformProperties, BitProperties, HistogramProperties
from properties import DetectionProperties, FatColorProperties, FilterProperties
class ProcessingBar(BoxLayout):
ui = ObjectProperty(None)
image_currant = str()
index = -1
p = [DefaultProperties(), TransformProperties(ui=ui), BitProperties(), HistogramProperties(ui=ui),
FilterProperties(), DetectionProperties(), FatColorProperties()]
def add_properties(self, index):
self.index = index
self.clear_widgets()
self.p[index].ui = self.ui
self.add_widget(Label(text='Propriedades', size_hint=(1, 0.2)))
self.add_widget(self.p[index])
self.add_widget(RevertButton(
self.ui, self, text='Reverter', size_hint=(1, 0.3)))
self.add_widget(CloseButton(
self.ui, text='Fechar Imagem', size_hint=(1, 0.3)))
try:
self.set_histogram(self.ui.pdi_space.get_image().source)
except AttributeError:
pass
def set_histogram(self, filename):
if self.index == 3:
self.p[self.index].set_histogram(filename)
self.p[self.index].hist.reload()
class RevertButton(Button):
def __init__(self, ui, processing_bar, **kwargs):
self.pb = processing_bar
self.ui = ui
super(RevertButton, self).__init__(**kwargs)
def on_press(self):
self.ui.pdi_space.set_source_image(self.pb.image_currant)
self.ui.pdi_space.get_image().reload()
self.ui.processing_bar.set_histogram(self.pb.image_currant)
class CloseButton(Button):
def __init__(self, ui, **kwargs):
self.ui = ui
super(CloseButton, self).__init__(**kwargs)
def on_press(self):
panel_images = self.ui.pdi_space.panel_images
panel_images.content.source = " "
panel_images.remove_widget(panel_images.content)
panel_images.remove_widget(panel_images.current_tab)
try:
panel_images.switch_to(panel_images.tab_list[0], do_scroll=False)
except IndexError:
panel_images.clear_widgets()