WIn (Form)
import clr
clr.AddReference("PresentationFramework")
clr.AddReference("PresentationCore");
clr.AddReference('System.Data')
clr.AddReference('System.Windows.Forms')
import System
from System import *
from System.Data import *
from System.Type import GetType
from System.Threading.Tasks import Task
from System.Windows import *
from System.Windows.Controls import *
from System.Windows.Controls.Primitives import *
from System.Windows.Media import *
from System.Windows.Media.Imaging import *
from System.Windows.Media.Effects import *
from System.Windows.Shapes import Rectangle
from System.Windows.Data import Binding
from System.Windows.Ink import Stroke
from Microsoft.Win32 import ( OpenFileDialog, SaveFileDialog )
import icon
class Win(Window):
def __init__(self,title=None,width=None,height=None):
import vbox
self.Closing += self.on_close
if title: self.Title = title
if width: self.Width = width
if height:self.Height= height
self.vbox = vbox.WpfVBox()
self.Content = self.vbox.ctrl
self.menubar = None
self.toolbar = None
self.statusbar = None
self.content = None
def set_title(self,title): self.Title = title
def set_icon(self,image): self.Icon = image
def set_iconfile(self,imagefile): self.Icon = self.get_imagefile(imagefile)
def set_width(self,width): self.Width = width
def set_height(self,height): self.Height = height
def set_size(self,width,height): self.Width = width; self.Height = height
def set_content(self,content): self.content = content
def add_menubar(self,menu): self.menubar = menu
def add_toolbar(self,tool): self.toolbar = tool
def add_statusbar(self,status): self.statusbar = status
def run(self):
if self.menubar: self.vbox.add_item(self.menubar,expand=False)
if self.toolbar: self.vbox.add_item(self.toolbar,expand=False)
if self.content: self.vbox.add_item(self.content,expand=True)
if self.statusbar: self.vbox.add_item(self.statusbar,expand=False)
self.Show();
Application().Run(self)
def close(self): self.Close()
def on_close(self,sender,event):
rv = MessageBox.Show("Do you want to close ?", "Warning", MessageBoxButton.YesNo )
if rv == MessageBoxResult.Yes:
event.Cancel = False
else:
event.Cancel = True
def get_imagefile(self,filename):
return icon.GetBitmapFrameFromFile(filename)
if __name__ == "__main__":
import menu
import tool
import status
import icon as ic
def setMenuBar():
m = menu.WpfMenuBar()
m.add_menu("File");
m.add_item("Exit", lambda s,e: app.Close())
m.add_separater()
m.add_item("Exit", icon=ic.GetExitBitmapImage(), handler=lambda s,e: app.Close())
app.add_menubar(m.ctrl)
def setToolBar():
t = tool.WpfToolBar()
t.add_toolbar();
button = Button()
button.Content = "Exit"
button.Click += lambda s,e: app.Close()
t.add_item(button)
t.add_separater()
stack = StackPanel()
img = Image()
img.Width = 16
img.Height = 16
img.Source = ic.GetExitBitmapImage()
stack.Children.Add(img)
button = Button()
button.Content = stack
button.Click += lambda s,e: app.Close()
t.add_item(button)
app.add_toolbar(t.ctrl)
def setStatusBar():
s = status.WpfStatusBar()
button = Button()
button.Content = "Exit"
button.Click += lambda s,e: app.Close()
s.add_item(button)
stack = StackPanel()
button = Button()
button.Content = stack
button.Click += lambda s,e: app.Close()
img = Image()
img.Source = ic.GetExitBitmapImage()
img.Width = 16
img.Height = 16
stack.Children.Add(img)
s.add_item(button)
app.add_statusbar(s.ctrl)
def setContent():
content = Button()
content.Content = "Content"
app.set_content(content)
app = Win("Window Demo",320,240)
app.set_icon(icon.GetExitBitmapImage())
#app.set_icon(icon.GetBitmapFrameFromFile("exit.png"))
setMenuBar()
setToolBar()
setContent()
setStatusBar()
app.run()
댓글 없음:
댓글 쓰기