def LoadDfmFile(FileName): Stream = vcl.TFileStream(FileName, 0x20) Stream2 = vcl.TMemoryStream() vcl.ObjectTextToBinary(Stream, Stream2) Stream2.Position = 0 Form = vcl.TForm(None) Stream2.ReadComponent(Form) return Form
def __init__(self): self.LastIndex = 0 # Indicates position after prompt, i.e. start of command self.Command = "" self.TextCache = [""] self.CacheIndex = 0 self.IndentLevel = 0 self.InputPromptActive = False self.Form = vcl.TForm(None, OnClose=self.Close, Width=vcl.Screen.Width // 2, Height=vcl.Screen.Height // 3) self.Form.Caption = "Python interpreter" self.RichEdit = vcl.TRichEdit(None, Parent=self.Form, Align="alClient", ScrollBars="ssVertical", WantTabs=True, OnKeyDown=self.KeyDown, OnKeyPress=self.KeyPress) self.RichEdit.Font.Name = "Courier New" self.RichEdit.Font.Size = 10 self.PopupMenu = vcl.TPopupMenu(None) self.PopupMenu.Items.Add( vcl.TMenuItem(self.PopupMenu, Caption="Clear", _owned=False, OnClick=self.Clear)) self.Form.PopupMenu = self.PopupMenu self.Form.Canvas.Font.Assign(self.RichEdit.Font) CharWidth = (self.Form.Canvas.TextWidth("A") * 15) // 22 self.RichEdit.Paragraph.TabCount = 22 x = CharWidth * 4 for I in range(0, 22): x += CharWidth * 2 # self.RichEdit.Paragraph.Tab[I] = x self.WritePrompt() self.stdout = sys.stdout sys.stdout = OutputReplacement(self, 0) self.stdin = sys.stdin sys.stdin = self self.stderr = sys.stderr sys.stderr = OutputReplacement(self, 0xFF)
def __init__(self, ShowCancel=True, **keywords): self.form = vcl.TForm(None, **keywords) self.Name = self.__class__.__name__ self.Position = "poMainFormCenter" self.BorderStyle = "bsDialog" self.BorderIcons = "biSystemMenu" self.panel = vcl.TPanel(None, Parent=self.form, BevelInner="bvRaised", BevelOuter="bvLowered", Left=8, Top=8, Width=self.ClientWidth - 16, Height=self.ClientHeight - 50, Caption="", Anchors="akLeft,akTop,akRight,akBottom") self.button1 = vcl.TButton(None, Parent=self.form, Caption=Utility.GetText("OK"), Anchors="akRight,akBottom", Default=True, OnClick=self.OnOk, Top=self.ClientHeight - 32, Left=self.ClientWidth - 176) if ShowCancel: self.button2 = vcl.TButton(None, Parent=self.form, Caption=Utility.GetText("Cancel"), Anchors="akRight,akBottom", ModalResult=1, Cancel=True, Top=self.ClientHeight - 32, Left=self.ClientWidth - 88) else: self.button2 = None self.button1.Cancel = True self.button1.Anchors = "akLeft,akRight,akBottom" self.button1.Left = (self.ClientWidth - self.button1.Width) / 2 self.OnShow = self.FormOnShow