Browse Source

Add outside fridge label, disable notifications

Rechner 1 year ago
parent
commit
86fefd1def
3 changed files with 69 additions and 10 deletions
  1. 24
    10
      main.py
  2. 36
    0
      resources/nametag/outside/default.html
  3. 9
    0
      resources/nametag/outside/outside.conf

+ 24
- 10
main.py View File

@@ -74,10 +74,15 @@ class Controls(wx.Frame):
74 74
         bold = wx.Font(20, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD, False)
75 75
 
76 76
         self.snipsBtn = wx.Button(self, wx.ID_ANY, "Idle")
77
+        self.snipsBtn.Bind(wx.EVT_BUTTON, self.close)
77 78
 
78
-        self.printBtn = wx.Button(self, wx.ID_ANY, "Date Label")
79
-        self.printBtn.SetFont(bold)
80
-        self.printBtn.Bind(wx.EVT_BUTTON, self.print_date)
79
+        self.dateBtn = wx.Button(self, wx.ID_ANY, "Date Label")
80
+        self.dateBtn.SetFont(bold)
81
+        self.dateBtn.Bind(wx.EVT_BUTTON, self.print_date)
82
+
83
+        self.outsideBtn = wx.Button(self, wx.ID_ANY, "Outside Label")
84
+        self.outsideBtn.SetFont(bold)
85
+        self.outsideBtn.Bind(wx.EVT_BUTTON, self.print_outside)
81 86
         
82 87
         self.nameBtn = wx.Button(self, wx.ID_ANY, "Name Label")
83 88
         self.nameBtn.SetFont(bold)
@@ -99,16 +104,20 @@ class Controls(wx.Frame):
99 104
         self.SetBackgroundColour("black")
100 105
         self.ShowFullScreen(True)
101 106
 
107
+        vsizer_left = wx.BoxSizer(wx.VERTICAL)
108
+        vsizer_left.Add(self.dateBtn, -1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTRE, 0)
109
+        vsizer_left.Add(self.outsideBtn, -1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTRE, 0)
110
+
102 111
         hsizer_top = wx.BoxSizer(wx.HORIZONTAL)
103
-        hsizer_top.Add(self.printBtn, -1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTRE, 0)
112
+        hsizer_top.Add(vsizer_left, -1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTRE, 0)
104 113
         hsizer_top.Add(self.nameBtn, -1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTRE, 0)
105 114
 
106 115
         sizer.Add(self.snipsBtn, -1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTRE, 0)
107
-        sizer.Add(hsizer_top, 2, wx.ALL|wx.EXPAND|wx.ALIGN_CENTRE, 20)
116
+        sizer.Add(hsizer_top, 2, wx.ALL|wx.EXPAND|wx.ALIGN_CENTRE, 10)
108 117
 
109 118
         hsizer = wx.BoxSizer(wx.HORIZONTAL)
110 119
 
111
-        sizer.Add(hsizer, 1, wx.ALL|wx.EXPAND, 20)
120
+        sizer.Add(hsizer, 1, wx.ALL|wx.EXPAND, 10)
112 121
         hsizer.Add(self.kitchenBtn, -1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTRE, 0)
113 122
         hsizer.Add(self.diningBtn, -1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTRE, 0)
114 123
         self.SetSizer(sizer)
@@ -167,6 +176,10 @@ class Controls(wx.Frame):
167 176
         #self.namePanel.Disable()
168 177
         #wx.CallLater(4000, self.hide_name_menu)
169 178
 
179
+    def print_outside(self, event):
180
+        self.printer.nametag(theme='outside')
181
+        self.printer.printout(printer='Zebra_2824')
182
+        wx.CallLater(4000, self.printer.cleanup, [self.printer.pdf,]) 
170 183
 
171 184
     
172 185
     @staticmethod
@@ -174,11 +187,12 @@ class Controls(wx.Frame):
174 187
         print("Published: {0}: {1}".format(userdata, result))
175 188
 
176 189
     def send_notification(self, title, text, icon="dialog-information"):
190
+        pass
177 191
         #subprocess.check_call(['/usr/bin/notify-send', str(title), str(text)])
178
-        self.notification = Notify.Notification.new(title, text)
179
-        self.notification.show()
192
+        #self.notification = Notify.Notification.new(title, text)
193
+        #self.notification.show()
180 194
         # Since we might not be on the main thread (?)
181
-        wx.CallAfter(self.queue_close_notifiaction)
195
+        #wx.CallAfter(self.queue_close_notifiaction)
182 196
 
183 197
     def queue_close_notifiaction(self, event=None):
184 198
         wx.CallLater(20000, self.close_notification)
@@ -242,7 +256,7 @@ class Controls(wx.Frame):
242 256
             self.GetEventHandler().ProcessEvent(event)
243 257
 
244 258
         self.mqtt.on_message = on_message
245
-        while True
259
+        while True:
246 260
             self.mqtt.loop()
247 261
             if self.MQTT_EXIT.isSet():
248 262
                 return None

+ 36
- 0
resources/nametag/outside/default.html View File

@@ -0,0 +1,36 @@
1
+<!doctype html>
2
+<html>
3
+<head>
4
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
5
+    <title></title>
6
+    <style>
7
+      body {
8
+        font-family: sans;
9
+      }
10
+      .container {
11
+        width: 100%;
12
+      }
13
+
14
+      .name {
15
+        font-size: 22px;
16
+	font-weight: bold;
17
+	text-align: center;
18
+      }
19
+
20
+      .date {
21
+        font-size: 16px;
22
+        text-align: center;
23
+      }
24
+
25
+      .sub {
26
+        text-align: center;
27
+      }
28
+    </style>
29
+</head>
30
+<body>
31
+  <div class="container">
32
+    <div class="date">More of this in</div>
33
+    <div class="name">Outside Fridge</div>
34
+  </div>
35
+</body>
36
+</html>

+ 9
- 0
resources/nametag/outside/outside.conf View File

@@ -0,0 +1,9 @@
1
+[default]
2
+zoom = 1  #;zoom factor
3
+height = 50  #;size of page in mm, while in portrait mode
4
+width = 24
5
+left = 0
6
+top = 0
7
+bottom = 0
8
+right = 0
9
+orientation = landscape