Made Popup accept a width_req argument

This commit is contained in:
Asmageddon 2012-07-12 15:58:39 +02:00
parent 8c9a89bcd2
commit 33e5cad75a

View File

@ -331,12 +331,13 @@ class MessagePopup(Popup):
""" """
Popup that just displays a message Popup that just displays a message
""" """
def __init__(self, parent_mode, title, message, align=ALIGN.DEFAULT): def __init__(self, parent_mode, title, message, align=ALIGN.DEFAULT, width_req=0.5):
self.message = message self.message = message
self.width= int(parent_mode.cols/2) #self.width= int(parent_mode.cols/2)
Popup.__init__(self,parent_mode, title, align=align, width_req=width_req)
lns = format_utils.wrap_string(self.message,self.width-2,3,True) lns = format_utils.wrap_string(self.message,self.width-2,3,True)
hr = min(len(lns)+2,int(parent_mode.rows/2)) self.height_req = min(len(lns)+2,int(parent_mode.rows/2))
Popup.__init__(self,parent_mode, title, align=align, height_req=hr) self.handle_resize()
self._lines = lns self._lines = lns
def handle_resize(self): def handle_resize(self):