def __init__(self, parent, session):
wx.Frame.__init__(self, parent, wx.ID_ANY, 'Messages', size=(240,500))
self.panel = scrolledpanel.ScrolledPanel(parent = self, id = -1)
self.panel.SetupScrolling()
self.SetBackgroundColour(wx.Colour(100,100,100))
self.session = session
self.display_matches()
python类Colour()的实例源码
def GenerateProjectTreeBranch(self, root, infos, item_alone=False):
to_delete = []
item_name = infos["name"]
if infos["type"] in ITEMS_UNEDITABLE:
if len(infos["values"]) == 1:
return self.GenerateProjectTreeBranch(root, infos["values"][0], True)
item_name = _(item_name)
self.ProjectTree.SetItemText(root, item_name)
self.ProjectTree.SetPyData(root, infos)
highlight_colours = self.Highlights.get(infos.get("tagname", None), (wx.Colour(255, 255, 255, 0), wx.BLACK))
self.ProjectTree.SetItemTextColour(root, highlight_colours[1])
self.ProjectTree.SetItemExtraImage(root, None)
if infos["type"] == ITEM_POU:
self.ProjectTree.SetItemImage(
root, self.TreeImageDict[self.Controler.GetPouBodyType(infos["name"])])
if item_alone:
self.ProjectTree.SetItemExtraImage(root, self.Controler.GetPouType(infos["name"]))
elif "icon" in infos and infos["icon"] is not None:
icon_name = infos["icon"]
if icon_name not in self.TreeImageDict:
self.TreeImageDict[icon_name] = self.TreeImageList.Add(GetBitmap(icon_name))
self.ProjectTree.SetItemImage(root, self.TreeImageDict[icon_name])
elif infos["type"] in self.TreeImageDict:
self.ProjectTree.SetItemImage(root, self.TreeImageDict[infos["type"]])
item, root_cookie = self.ProjectTree.GetFirstChild(root)
for values in infos["values"]:
if values["type"] not in ITEMS_UNEDITABLE or len(values["values"]) > 0:
if item is None or not item.IsOk():
item = self.ProjectTree.AppendItem(root, "")
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
self.GenerateProjectTreeBranch(item, values)
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
while item is not None and item.IsOk():
to_delete.append(item)
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
for item in to_delete:
self.ProjectTree.Delete(item)
def RefreshScaling(self, refresh=True):
properties = self.Controler.GetProjectProperties(self.Debug)
scaling = properties["scaling"][self.CurrentLanguage]
if scaling[0] != 0 and scaling[1] != 0:
self.Scaling = scaling
if self.DrawGrid:
width = max(2, int(scaling[0] * self.ViewScale[0]))
height = max(2, int(scaling[1] * self.ViewScale[1]))
bitmap = wx.EmptyBitmap(width, height)
dc = wx.MemoryDC(bitmap)
dc.SetBackground(wx.Brush(self.Editor.GetBackgroundColour()))
dc.Clear()
dc.SetPen(MiterPen(wx.Colour(180, 180, 180)))
dc.DrawPoint(0, 0)
self.GridBrush = wx.BrushFromBitmap(bitmap)
else:
self.GridBrush = wx.TRANSPARENT_BRUSH
else:
self.Scaling = None
self.GridBrush = wx.TRANSPARENT_BRUSH
page_size = properties["pageSize"]
if page_size != (0, 0):
self.PageSize = map(int, page_size)
self.PagePen = MiterPen(wx.Colour(180, 180, 180))
else:
self.PageSize = None
self.PagePen = wx.TRANSPARENT_PEN
if refresh:
self.RefreshVisibleElements()
self.Editor.Refresh(False)
# -------------------------------------------------------------------------------
# Refresh functions
# -------------------------------------------------------------------------------
def __init__(self, parent):
wx.Panel.__init__ ( self, parent, id = wx.ID_ANY,
pos = wx.DefaultPosition, size = wx.Size(256,80),
style = wx.SIMPLE_BORDER|wx.TAB_TRAVERSAL )
self.init_buf()
self.data, self.extent = [], [0,0,1,1]
self.set_title_label('Graph', 'X-unit', 'Y-unit')
self.update = False
self.SetBackgroundColour( wx.Colour( 255, 255, 255 ) )
self.Bind(wx.EVT_SIZE, self.on_size)
self.Bind(wx.EVT_PAINT, self.on_paint)
self.Bind(wx.EVT_IDLE, self.on_idle)
self.Bind(wx.EVT_MOTION, self.on_move )
def __set_properties(self):
# begin wxGlade: Institution.__set_properties
self.SetBackgroundColour(wx.Colour(47, 47, 47))
self.SetTitle("Institution")
self.SetSize((550, 303))
self.SetFocus()
self.label_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.label_2.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.text_ctrl_5.SetFont(wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.text_ctrl_5.SetMinSize((250, 27))
self.label_4.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.text_ctrl_6.SetFont(wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.label_6.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.text_ctrl_1.SetMinSize((250, 27))
self.label_7.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.text_ctrl_2.SetMinSize((250, 27))
self.label_8.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.text_ctrl_3.SetMinSize((250, 27))
self.button_1.SetMinSize((80, 33))
self.button_2.SetMinSize((80, 33))
self.button_1.SetBackgroundColour(wx.Colour(33, 137, 33))
self.button_1.SetForegroundColour(wx.Colour(255, 255, 255))
self.button_2.SetBackgroundColour(wx.Colour(33, 137, 33))
self.button_2.SetForegroundColour(wx.Colour(255, 255, 255))
self.label_1.SetForegroundColour(wx.Colour(255, 255, 255))
self.label_2.SetForegroundColour(wx.Colour(255, 255, 255))
self.label_4.SetForegroundColour(wx.Colour(255, 255, 255))
self.label_6.SetForegroundColour(wx.Colour(255, 255, 255))
self.label_7.SetForegroundColour(wx.Colour(255, 255, 255))
self.label_8.SetForegroundColour(wx.Colour(255, 255, 255))
# end wxGlade
def __set_properties(self):
# begin wxGlade: sampoorna_win.__set_properties
self.SetTitle(_("frame_1"))
self.panel_warning.SetForegroundColour(wx.Colour(201, 0, 0))
self.panel_warning.Hide()
self.panel_1.SetScrollRate(10, 10)
# end wxGlade
def __set_properties(self):
# begin wxGlade: sampoorna_win.__set_properties
self.SetTitle(_("Import from Sampoorna"))
self.SetSize((894, 640))
self.label_1.SetForegroundColour(wx.Colour(204, 50, 50))
self.label_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
self.label_2.SetForegroundColour(wx.Colour(95, 159, 159))
self.label_2.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
self.label_3.SetForegroundColour(wx.Colour(185, 115, 45))
self.label_3.SetFont(wx.Font(11, wx.DEFAULT, wx.ITALIC, wx.BOLD, 0, ""))
self.text_ctrl_user.SetMinSize((250, 35))
self.label_4.SetForegroundColour(wx.Colour(185, 115, 45))
self.label_4.SetFont(wx.Font(11, wx.DEFAULT, wx.ITALIC, wx.BOLD, 0, ""))
self.text_ctrl_passw.SetMinSize((250,35))
self.panel_1.SetBackgroundColour(wx.Colour(193, 193, 255))
self.button_next.SetMinSize((100, 35))
self.login_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
self.login_pane.SetFocus()
self.checkbox_8.SetMinSize((100, 30))
self.checkbox_9.SetMinSize((100, 30))
self.checkbox_10.SetMinSize((120, 30))
self.panel_3.SetBackgroundColour(wx.Colour(193, 193, 255))
self.button_next_copy_copy.SetMinSize((100, 35))
self.button_next_copy.SetMinSize((100, 35))
self.standard_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
self.standard_pane.Hide()
self.progresss_total.SetMinSize((400, 30))
self.progress_each.SetMinSize((400, 30))
self.text_ctrl_1.SetMinSize((450, 400))
self.text_ctrl_1.SetBackgroundColour(wx.Colour(204, 204, 204))
self.text_ctrl_1.SetForegroundColour(wx.Colour(17, 17, 71))
self.text_ctrl_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
self.button_finished.SetMinSize((100, 35))
self.panel_2.SetBackgroundColour(wx.Colour(193, 193, 255))
self.report_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
# end wxGlade
def __set_properties(self):
# begin wxGlade: sampoorna_win.__set_properties
self.SetTitle(_("Import from Sampoorna"))
self.SetSize((894, 640))
self.label_1.SetForegroundColour(wx.Colour(204, 50, 50))
self.label_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
self.label_2.SetForegroundColour(wx.Colour(95, 159, 159))
self.label_2.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
self.label_3.SetForegroundColour(wx.Colour(185, 115, 45))
self.label_3.SetFont(wx.Font(11, wx.DEFAULT, wx.ITALIC, wx.BOLD, 0, ""))
self.text_ctrl_user.SetMinSize((250, 35))
self.label_4.SetForegroundColour(wx.Colour(185, 115, 45))
self.label_4.SetFont(wx.Font(11, wx.DEFAULT, wx.ITALIC, wx.BOLD, 0, ""))
self.text_ctrl_passw.SetMinSize((250,35))
self.panel_1.SetBackgroundColour(wx.Colour(193, 193, 255))
self.button_next.SetMinSize((100, 35))
self.login_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
self.login_pane.SetFocus()
self.checkbox_8.SetMinSize((100, 30))
self.checkbox_9.SetMinSize((100, 30))
self.checkbox_10.SetMinSize((120, 30))
self.panel_3.SetBackgroundColour(wx.Colour(193, 193, 255))
self.button_previous.SetMinSize((100, 35))
self.button_proceed.SetMinSize((100, 35))
self.standard_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
self.standard_pane.Hide()
self.progresss_total.SetMinSize((400, 30))
self.progress_each.SetMinSize((400, 30))
self.button_finished.SetMinSize((100, 35))
self.panel_2.SetBackgroundColour(wx.Colour(193, 193, 255))
self.report_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
'''self.report_pane.Hide()
self.button_finished.Hide()
self.button_next.Disable()
self.button_proceed.Disable()
'''
# end wxGlade
def error_report(self,msg):
data = msg.data
self.label_status.SetForegroundColour(wx.Colour(204, 50, 50))
self.label_status.SetLabel(str(data))
self.stop_animation('')
self.label_status.Wrap(300)
def update_display(self, msg):
"""
Receives data from thread and updates the display
"""
data = msg.data
self.label_satus.SetLabel("Status: "+str(data))
if data=="Successfully Logged in" or data=="Aborted" :
self.text_ctrl_report.Value="\n"+data+self.text_ctrl_report.Value
if data.find("Fetching Data from remote server")!=-1:
self.text_ctrl_report.Value="\n Preparations made for download"+self.text_ctrl_report.Value
if data.find("Processeing Data")!=-1:
self.text_ctrl_report.Value="\n Downloaded data for the class"+self.text_ctrl_report.Value
if data.find("Writing to Local Database")!=-1:
self.text_ctrl_report.Value="\n Data Processing Completed for the class"+self.text_ctrl_report.Value
if data.find("Updation Completed ")!=-1:
self.text_ctrl_report.Value="\n Database Updated for the class" +self.text_ctrl_report.Value
#self.list_ctrl_1.Append(str(data))
if msg.data=="Invalid Username Password combination":
self.button_finished.SetLabel("Close")
self.text_ctrl_report.SetForegroundColour(wx.Colour(204, 50, 50))
self.text_ctrl_report.Value=msg.data
else: #some error
self.text_ctrl_report.SetForegroundColour(wx.Colour(204, 50, 50))
self.text_ctrl_report.Value=msg.data
def __set_properties(self):
# begin wxGlade: add_div.__set_properties
self.SetTitle("Year & Division")
self.SetSize((600, 500))
#self.Enable(False)
self.SetFocus()
self.label_1.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.combo_box_1.SetSelection(0)
self.label_2.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.combo_box_2.SetSelection(0)
self.list_box_1.SetMinSize((150, 257))
self.list_box_1.SetBackgroundColour(wx.Colour(255, 255, 255))
self.list_box_1.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.button_1.SetMinSize((120, 40))
self.text_ctrl_1.SetMinSize((90, 33))
self.text_ctrl_1.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
self.text_ctrl_1.Value='Eg: A-K'
self.text_ctrl_1.SetForegroundColour('#9CA998')
self.button_2.SetMinSize((120, 40))
self.button_1.Enable(False)
self.button_2.Enable(False)
self.button_3.SetMinSize((85, 35))
self.panel_1.SetScrollRate(10, 10)
# end wxGlade
def setup(self):
menubar = wx.MenuBar()
filem = wx.Menu()
helpm = wx.Menu()
setm = wx.Menu()
new = filem.Append(wx.ID_NEW, '&New Tournament')
open_ = filem.Append(wx.ID_OPEN, '&Open Tournament')
filem.AppendSeparator()
self.Bind(wx.EVT_MENU, self.new_event, new)
qmi = wx.MenuItem(filem, wx.ID_EXIT, '&Quit\tCtrl+W')
filem.AppendItem(qmi)
about = helpm.Append(wx.ID_ANY, '&About BP5000')
options = setm.Append(wx.ID_ANY, '&Options')
self.Bind(wx.EVT_MENU, self.quit_event, qmi)
self.Bind(wx.EVT_MENU, self.load_event, open_)
self.Bind(wx.EVT_MENU, self.about_event, about)
self.Bind(wx.EVT_MENU, self.options_event, options)
self.options = Options()
menubar.Append(filem, '&File')
menubar.Append(setm, '&Settings')
menubar.Append(helpm, '&Help')
self.SetMenuBar(menubar)
p = wx.Panel(self)
self.nb = fnb.FlatNotebook(p, agwStyle=fnb.FNB_X_ON_TAB)
def pagechanged(event):
col = wx.Colour(hash(self.nb.GetPage(event.GetSelection()).sname))
self.nb.SetActiveTabColour(col)
if isinstance(self.nb.GetPage(event.GetSelection()), BracketPage):
self.nb.GetPage(event.GetSelection()).updatebracketimg()
self.nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, pagechanged)
sz = wx.BoxSizer()
sz.Add(self.nb, 1, wx.EXPAND)
p.SetSizer(sz)
self.Bind(wx.EVT_CLOSE, self.quit_event)
self.SetSize((950, 650))
self.SetTitle('BP5000')
self.Centre()
self.Show(True)
def __init__(self, parent):
wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=(0, 0), size=(480, 320))
self.parent = parent
self.bitmap_1 = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap("./gui/users.png", wx.BITMAP_TYPE_ANY), pos=(0, 0))
users = get_users()
self.names = list()
for user in users:
if user.isshown and not user.onlyrfid:
self.names.append(user.longname)
self.but_names = list()
self.position = 0
self.lines = 4
self.items = len(self.names)
for i in range(self.lines):
#480x320
self.but = wx.lib.platebtn.PlateButton(self, label=self.names[self.position+i] if self.position+i < len(self.names) else "", pos=(3, 3+i*80),
style=wx.BU_EXACTFIT | wx.lib.platebtn.PB_STYLE_SQUARE)
self.but.SetSize((365, 74))
self.but.SetBackgroundColour((255-(i*20 % 40), (160+(i*50 % 100)), 0))
#self.but.SetForegroundColour("#006699")
self.but.SetPressColor(wx.Colour(255,255,255,0))
self.but.SetFont(wx.Font(25, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans"))
self.but.Bind(wx.EVT_LEFT_DOWN, parent.onUser, id=self.but.Id)
self.but_names.append(self.but)
self.b_up = wx.Button(self, id=wx.ID_ANY, label=u"\u25B2", pos=(374, 0), size=(106, 106))
self.b_up.SetFont(wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans"))
self.b_up.Bind(wx.EVT_LEFT_DOWN, self.on_up, id=self.b_up.Id)
self.b_down = wx.Button(self, id=wx.ID_ANY, label=u"\u25BC", pos=(374, 214), size=(106, 106))
self.b_down.SetFont(wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans"))
self.b_down.Bind(wx.EVT_LEFT_DOWN, self.on_down, id=self.b_down.Id)
self.b_exit = wx.Button(self, id=wx.ID_ANY, label="X", pos=(374, 107), size=(106, 106))
self.b_exit.SetFont(wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans"))
self.b_exit.Bind(wx.EVT_LEFT_DOWN, parent.onExit, id=self.b_exit.Id)
self.Layout()
def __init__(self):
wx.Frame.__init__(self, None, -1, 'CanvasFrame', size=(550, 350))
color = wx.Colour("WHITE")
self.SetBackgroundColour(color)
self.figure = Figure()
self.axes = self.figure.add_subplot(111)
t = arange(0.0, 3.0, 0.01)
s = sin(2 * pi * t)
self.axes.plot(t, s)
self.canvas = FigureCanvas(self, -1, self.figure)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.SetSizerAndFit(self.sizer)
self.add_toolbar()
def set_online(self, module_name, channel):
if module_name in self.chats:
if channel.lower() in self.chats[module_name]:
self.chats[module_name][channel.lower()]['status'].SetBackgroundColour(wx.Colour(0, 128, 0))
self.Layout()
self.Refresh()
def __init__(self, x0, y0, x1, y1):
self.xList = [x0, x1]
self.yList = [y0, y1]
self.P_color = wx.Colour(50,50,50)
def __init__(self, x, y, color, property = 0):
self.pos_x = x
self.pos_y = y
self.rad = 10
self.property = property
self.B_color = color
self.P_color = wx.Colour(50,50,50)
def __init__(self, panel, x, y, epsilon = 0.99):
super(Agent, self).__init__(
x, y, wx.Colour(112,146,190)
)
self.dir_Angle = math.pi/4
self.speed = 5
self.pos_x_max, self.pos_y_max = panel.GetSize()
self.eyes = [ EYE(i) for i in range(0, NUM_EYES)]
self.actions = [-math.pi/16, -math.pi/8, 0.0, math.pi/8, math.pi/16]
self.prevActions = np.zeros_like(self.actions)
# DQN Model
self.model = Q()
self.optimizer = optimizers.Adam()
self.optimizer.setup(self.model)
self.epsilon = epsilon
self.eMem = np.array([],dtype = np.float32)
self.memPos = 0
self.memSize = 30000
self.batch_num = 30
self.gamma = 0.7
self.loss = 0.0
self.State = SState()
self.prevState = np.ones((1,STATE_DIM))
def Draw(self, dc):
dc.SetPen(wx.Pen(self.P_color))
dc.SetBrush(wx.Brush(self.B_color))
for e in self.eyes:
if e.obj == 1:
dc.SetPen(wx.Pen(wx.Colour(112,173,71)))
elif e.obj == 2:
dc.SetPen(wx.Pen(wx.Colour(237,125,49)))
else:
dc.SetPen(wx.Pen(self.P_color))
dc.DrawLine(self.pos_x, self.pos_y,
self.pos_x + e.SightDistance*math.sin(self.dir_Angle + e.OffSetAngle),
self.pos_y - e.SightDistance*math.cos(self.dir_Angle + e.OffSetAngle))
super(Agent, self).Draw(dc)
def __init__(self, parent=None, id=-1, title=None):
wx.Frame.__init__(self, parent, id, title)
self.panel = wx.Panel(self, size=(640, 480))
self.panel.SetBackgroundColour('WHITE')
self.Fit()
self.A = Agent(self.panel, 150, 100 )
self.greenB = [Ball(rnd.randint(40, 600),rnd.randint(40, 440),
wx.Colour(112,173,71), property = 1) for i in range(0, 15)]
self.redB = [Ball(rnd.randint(40, 600),rnd.randint(40, 440),
wx.Colour(237,125,49), property = 2) for i in range(0, 10)]
# OutrBox
self.Box = Walls(640, 480, 0, 480)
self.Box.addPoint(0,0)
self.Box.addPoint(640,0)
self.Box.addPoint(640,480)
# Wall in the world
self.WallA = Walls(96, 90, 256, 90)
self.WallA.addPoint(256, 390)
self.WallA.addPoint(96,390)
self.Bind(wx.EVT_CLOSE, self.CloseWindow)
self.cdc = wx.ClientDC(self.panel)
w, h = self.panel.GetSize()
self.bmp = wx.EmptyBitmap(w,h)
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.OnTimer)
self.timer.Start(20)