forked from aker-gateway/Aker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.py
52 lines (40 loc) · 1.42 KB
/
popup.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ahmed Nazmy
#
# Meta
import urwid
import logging
class SimplePopupDialog(urwid.WidgetWrap):
"""
A dialog that appears with nothing but a close button
"""
signals = ['popup_close']
def __init__(self, message):
close_button = urwid.Button(u"OK")
urwid.connect_signal(close_button, 'click',
lambda button: self._emit("popup_close"))
pile = urwid.Pile([urwid.Text(message, align='center'), urwid.Padding(
close_button, align='center', left=13, right=13)])
fill = urwid.Filler(pile)
self.__super.__init__(urwid.AttrMap(urwid.LineBox(fill), 'popup'))
class SimplePopupLauncher(urwid.PopUpLauncher):
def __init__(self):
self.__super.__init__(urwid.Text(u"", align='right'))
self._message = None
@property
def message(self):
return self._message
@message.setter
def message(self, value):
self._message = value
def create_pop_up(self):
pop_up = SimplePopupDialog(self._message)
urwid.connect_signal(pop_up, 'popup_close',
lambda button: self.close_pop_up())
return pop_up
def get_pop_up_parameters(self):
return {'left': 1, 'top': 1, 'overlay_width': 35, 'overlay_height': 7}
def show_indicator(self, message):
self.original_widget.set_text(message)