X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/blobdiff_plain/346a9b8e1fcfe30629f0d1ee4675e9e8f89890cf..4c4732c6ed8cb0aaa70fb2d4c6e5a958868c5349:/src/pgu/gui/dialog.py
diff --git a/src/pgu/gui/dialog.py b/src/pgu/gui/dialog.py
deleted file mode 100644
index 0d30b34..0000000
--- a/src/pgu/gui/dialog.py
+++ /dev/null
@@ -1,168 +0,0 @@
-"""
-"""
-import os
-
-from const import *
-import table, area
-import basic, input, button
-import pguglobals
-
-class Dialog(table.Table):
- """A dialog window with a title bar and an "close" button on the bar.
-
-
Dialog(title,main)
-
-
- - title
- title widget, usually a label
-
- main
- main widget, usually a container
-
-
- Example
-
- title = gui.Label("My Title")
- main = gui.Container()
- #add stuff to the container...
-
- d = gui.Dialog(title,main)
- d.open()
-
- """
- def __init__(self,title,main,**params):
- params.setdefault('cls','dialog')
- table.Table.__init__(self,**params)
-
-
- self.tr()
- self.td(title,align=-1,cls=self.cls+'.bar')
- clos = button.Icon(self.cls+".bar.close")
- clos.connect(CLICK,self.close,None)
- self.td(clos,align=1,cls=self.cls+'.bar')
-
- self.tr()
- self.td(main,colspan=2,cls=self.cls+".main")
-
-
-# self.tr()
-#
-#
-# t = table.Table(cls=self.cls+".bar")
-# t.tr()
-# t.td(title)
-# clos = button.Icon(self.cls+".bar.close")
-# t.td(clos,align=1)
-# clos.connect(CLICK,self.close,None)
-# self.add(t,0,0)
-#
-# main.rect.w,main.rect.h = main.resize()
-# clos.rect.w,clos.rect.h = clos.resize()
-# title.container.style.width = main.rect.w - clos.rect.w
-#
-# self.tr()
-# self.td(main,cls=self.cls+".main")
-#
-
-
-class FileDialog(Dialog):
- """A file picker dialog window.
-
- FileDialog()
- Some optional parameters:
-
- - title_txt
- title text
-
- button_txt
- button text
-
- path
- initial path
-
- """
-
- def __init__(self, title_txt="File Browser", button_txt="Okay", cls="dialog", folderText = "Folder", fileText = "File", path=None, customFont = None, showCurDir = True, customWidth = 350, customHeight = 150):
-
- self.customFont = customFont
- self.showCurDir= showCurDir
- cls1 = 'filedialog'
- if not path: self.curdir = os.getcwd()
- else: self.curdir = path
- self.dir_img = basic.Image(
- pguglobals.app.theme.get(cls1+'.folder', '', 'image'))
- td_style = {'padding_left': 4,
- 'padding_right': 4,
- 'padding_top': 2,
- 'padding_bottom': 2}
- self.title = basic.Label(title_txt, cls=cls+".title.label")
- self.body = table.Table()
- self.list = area.List(width=customWidth, height=customHeight)
- self.input_dir = input.Input(customFont = self.customFont)
- self.input_file = input.Input(customFont = self.customFont)
- self._list_dir_()
- self.button_ok = button.Button(button_txt)
- self.body.tr()
- if self.showCurDir :
- self.body.td(basic.Label(folderText), style=td_style, align=-1)
- self.body.td(self.input_dir, style=td_style)
- self.body.tr()
- self.body.td(self.list, colspan=3, style=td_style)
- self.list.connect(CHANGE, self._item_select_changed_, None)
- self.button_ok.connect(CLICK, self._button_okay_clicked_, None)
- self.body.tr()
- self.body.td(basic.Label(fileText), style=td_style, align=-1)
- self.body.td(self.input_file, style=td_style)
- self.body.td(self.button_ok, style=td_style)
- self.value = None
- Dialog.__init__(self, self.title, self.body)
-
- def _list_dir_(self):
- self.input_dir.value = self.curdir
- self.input_dir.pos = len(self.curdir)
- self.input_dir.vpos = 0
- dirs = []
- files = []
- try:
- for i in os.listdir(self.curdir):
- if os.path.isdir(os.path.join(self.curdir, i)): dirs.append(i)
- else: files.append(i)
- except:
- self.input_file.value = "Opps! no access"
- #if '..' not in dirs: dirs.append('..')
- dirs.sort()
- dirs = ['..'] + dirs
-
- files.sort()
- for i in dirs:
- #item = ListItem(image=self.dir_img, text=i, value=i)
- if self.customFont == None :
- self.list.add(i,image=self.dir_img,value=i)
- else :
- label = basic.Label(i,font = self.customFont)
- self.list.add(label,image=self.dir_img,value=i)
- for i in files:
- #item = ListItem(image=None, text=i, value=i)
- if self.customFont == None :
- self.list.add(i,value=i)
- else:
- label = basic.Label(i,font = self.customFont)
- self.list.add(label,value=i)
- #self.list.resize()
- self.list.set_vertical_scroll(0)
- #self.list.repaintall()
-
-
- def _item_select_changed_(self, arg):
- self.input_file.value = self.list.value
- fname = os.path.abspath(os.path.join(self.curdir, self.input_file.value))
- if os.path.isdir(fname):
- self.input_file.value = ""
- self.curdir = fname
- self.list.clear()
- self._list_dir_()
-
-
- def _button_okay_clicked_(self, arg):
- if self.input_dir.value != self.curdir:
- if os.path.isdir(self.input_dir.value):
- self.input_file.value = ""
- self.curdir = os.path.abspath(self.input_dir.value)
- self.list.clear()
- self._list_dir_()
- else:
- self.value = os.path.join(self.curdir, self.input_file.value)
- self.send(CHANGE)
- self.close()