--- a/trunk/cforge/cforge/Package/CFORGE/Scripts/ui.py +++ b/trunk/cforge/cforge/Package/CFORGE/Scripts/ui.py @@ -6,7 +6,7 @@ from System.Drawing import Point, Font, FontStyle, Color, Icon from System.Windows.Forms import Application, Form, TextBox -from System.Windows.Forms import Label, ToolBar, ToolBarButton, OpenFileDialog, Button +from System.Windows.Forms import Label, ToolBar, ToolBarButton, OpenFileDialog, Button, ScrollBars from System.Windows.Forms import DialogResult, ScrollBars, DockStyle import sys import os @@ -17,7 +17,7 @@ class IFormSettings(Form): - def __init__(self, Title, Config, Folder=False, Credentials=False): + def __init__(self, Title, Config, Folder=False, Credentials=False, Info=False, InfoText="", Message=False): self.Config = Config y = 0 @@ -84,6 +84,50 @@ self.PassBox.Width = 300 y += 24 + if Info: + # Info Box + self.InfoLabel = Label() + self.InfoLabel.Text = "Info:" + self.InfoLabel.Location = Point(0, y) + self.InfoLabel.Width = 60 + self.InfoLabel.Parent = self + y += 24 + + self.InfoBox = TextBox() + self.InfoBox.Text = InfoText + self.InfoBox.Enabled = False + self.InfoBox.Location = Point(0, y) + self.InfoBox.Parent = self + self.InfoBox.WordWrap = False + self.InfoBox.Multiline = True + self.InfoBox.ScrollBars = ScrollBars.Horizontal | ScrollBars.Vertical + self.InfoBox.Width = 360 + self.InfoBox.Height = 260 + y += 280 + + if Message: + # Message + self.MessageLabel = Label() + self.MessageLabel.Text = "Message:" + self.MessageLabel.Location = Point(0, y) + self.MessageLabel.Width = 60 + self.MessageLabel.Parent = self + y += 24 + + self.MessageBox = TextBox() + self.MessageBox.Text = "Enter Message..." + if Config["msg"] != "": + self.MessageBox.Text = Config["msg"] + self.MessageBox.Enabled = True + self.MessageBox.Location = Point(0, y) + self.MessageBox.Parent = self + self.MessageBox.WordWrap = False + self.MessageBox.Multiline = True + self.MessageBox.ScrollBars = ScrollBars.Horizontal | ScrollBars.Vertical + self.MessageBox.Width = 360 + self.MessageBox.Height = 160 + y += 180 + # OK / Cancel Button self.AcceptButton = Button() self.AcceptButton.Click += self.OnClickOK @@ -132,6 +176,8 @@ self.Config["user"] = self.UserBox.Text if hasattr(self, 'PassBox'): self.Config["pass"] = self.PassBox.Text + if hasattr(self, 'MessageBox'): + self.Config["msg"] = self.MessageBox.Text GlobalResult = True self.Dispose() @@ -145,7 +191,7 @@ def GetSettings(): dirname = os.path.expanduser("~\\cforge") filename = dirname + "\\cache.json" - config = { 'folder' : dirname, 'user' : os.environ["USERNAME"], 'pass' : '' } + config = { 'folder' : dirname, 'user' : os.environ["USERNAME"], 'pass' : '', 'msg' : ''} if not os.path.isfile(filename): if not os.path.isdir(dirname): os.mkdir(dirname) @@ -162,14 +208,14 @@ with open(filename, "w") as f: config = json.dump(config, f) -def Dialog(Title, Folder=False, Credentials=False, DefaultFolder=""): +def Dialog(Title, Folder=False, Credentials=False, DefaultFolder="", Info=False, InfoText="", Message=False): config = GetSettings() if DefaultFolder != "": folder, file = ntpath.split(config['folder']) config['folder'] = os.path.join(folder, DefaultFolder) - Application.Run(IFormSettings(Title, Folder=Folder, Credentials=Credentials, Config=config)) + Application.Run(IFormSettings(Title, Folder=Folder, Credentials=Credentials, Info=Info, InfoText=InfoText, Message=Message, Config=config)) if GlobalResult: SaveSettings(config) return config