def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
box = wx.BoxSizer(wx.VERTICAL)
box.Add((20, 30))
keys = buttonDefs.keys()
for k in keys:
text = buttonDefs[k][1]
btn = wx.Button(self, k, text)
box.Add(btn, 0, wx.ALIGN_CENTER|wx.ALL, 15)
self.Bind(wx.EVT_BUTTON, self.OnButton, btn)
# put a GLCanvas on the wx.Panel
c = CubeCanvas(self)
c.SetMinSize((200, 200))
box.Add(c, 0, wx.ALIGN_CENTER|wx.ALL, 15)
c = ConeCanvas(self)
c.SetMinSize((200, 200))
box.Add(c, 0, wx.ALIGN_CENTER|wx.ALL, 15)
self.SetAutoLayout(True)
self.SetSizer(box)
python类ALIGN_CENTER的实例源码
import_OpenGL_cube_and_cone.py 文件源码
项目:Python-GUI-Programming-Cookbook-Second-Edition
作者: PacktPublishing
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def __init__(self, parent, id, title, message, download_url, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, name='dialog'):
wx.Dialog.__init__(self, parent, id, title, pos, size, style, name)
label = wx.StaticText(self, label=message)
button = wx.Button(self, id=wx.ID_OK, label="Close")
button.SetDefault()
line = wx.StaticLine(self, wx.ID_ANY, size=(20, -1), style=wx.LI_HORIZONTAL)
download_ctrl = hl.HyperLinkCtrl(self, wx.ID_ANY, download_url, URL=download_url)
sizer = wx.BoxSizer(wx.VERTICAL)
button_sizer = wx.StdDialogButtonSizer()
button_sizer.AddButton(button)
button_sizer.Realize()
sizer.Add(label, 0, wx.ALIGN_CENTER|wx.ALL, 5)
sizer.Add(download_ctrl, 0, wx.ALL, 10)
sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
sizer.Add(button_sizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
self.SetSizer(sizer)
sizer.Fit(self)
def initOptions(self):
optionsSizer = wx.BoxSizer(wx.HORIZONTAL)
kernTypeControlBox = widgets.ControlBox(self, label='Kernel Type', orient=wx.HORIZONTAL)
self.kernTypeComboBox = wx.ComboBox(self, choices=self.flt.kernMap.keys(),
value=self.flt.kernType, style=wx.CB_DROPDOWN)
self.Bind(wx.EVT_COMBOBOX, self.setKernType, self.kernTypeComboBox)
kernTypeControlBox.Add(self.kernTypeComboBox, proportion=1, flag=wx.ALL, border=8)
optionsSizer.Add(kernTypeControlBox, proportion=1,
flag=wx.ALL | wx.ALIGN_CENTER, border=8)
widthControlBox = widgets.ControlBox(self, label='Width', orient=wx.HORIZONTAL)
self.widthSpinCtrl = wx.SpinCtrl(self, value=str(self.flt.width), min=2, max=100)
self.Bind(wx.EVT_SPINCTRL, self.setWidth, self.widthSpinCtrl)
widthControlBox.Add(self.widthSpinCtrl, proportion=1, flag=wx.ALL, border=8)
optionsSizer.Add(widthControlBox, proportion=0,
flag=wx.TOP | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=8)
self.sizer.Add(optionsSizer, proportion=0)#, flag=wx.EXPAND)
def initOptions(self):
optionsSizer = wx.BoxSizer(wx.HORIZONTAL)
self.filtTypeComboBox = wx.ComboBox(self, choices=self.flt.filtMap.keys(),
value=self.flt.filtType, style=wx.CB_DROPDOWN)
self.Bind(wx.EVT_COMBOBOX, self.setFiltType, self.filtTypeComboBox)
optionsSizer.Add(self.filtTypeComboBox, proportion=1,
flag=wx.LEFT | wx.TOP | wx.RIGHT | wx.ALIGN_CENTER, border=20)
self.zeroPhaseCheckBox = wx.CheckBox(self, label='Zero Phase')
self.zeroPhaseCheckBox.SetValue(self.flt.zeroPhase)
self.Bind(wx.EVT_CHECKBOX, self.setZeroPhase, self.zeroPhaseCheckBox)
optionsSizer.Add(self.zeroPhaseCheckBox, proportion=1,
flag=wx.LEFT | wx.TOP | wx.ALIGN_CENTER, border=20)
self.sizer.Add(optionsSizer, proportion=0)#, flag=wx.EXPAND)
def __do_layout(self):
# begin wxGlade: Dialogo_user_pass.__do_layout
sizer_3 = wx.BoxSizer(wx.VERTICAL)
grid_sizer_4 = wx.FlexGridSizer(1, 2, 0, 0)
grid_sizer_1 = wx.FlexGridSizer(2, 2, 5, 5)
grid_sizer_1.Add(self.label_3, 0, 0, 0)
grid_sizer_1.Add(self.usuario, 0, 0, 0)
grid_sizer_1.Add(self.label_4, 0, 0, 0)
grid_sizer_1.Add(self.password, 0, 0, 0)
grid_sizer_1.AddGrowableCol(0)
sizer_3.Add(grid_sizer_1, 1, wx.ALIGN_CENTER | wx.ALIGN_RIGHT | wx.ALL | wx.EXPAND, 10)
grid_sizer_4.Add(self.button_OK, 0, 0, 0)
grid_sizer_4.Add(self.button_cancel, 0, wx.ALIGN_RIGHT, 0)
sizer_3.Add(grid_sizer_4, 1, wx.ALIGN_RIGHT | wx.ALL, 4)
self.SetSizer(sizer_3)
sizer_3.Fit(self)
self.Layout()
# end wxGlade
# end of class Dialogo_user_pass
def __do_layout(self):
# begin wxGlade: Dialogo_acceso_vcenter.__do_layout
sizer_6 = wx.BoxSizer(wx.VERTICAL)
grid_sizer_6 = wx.FlexGridSizer(1, 2, 0, 0)
grid_sizer_5 = wx.FlexGridSizer(4, 2, 5, 5)
grid_sizer_5.Add(self.label_7, 0, 0, 0)
grid_sizer_5.Add(self.nombre_vcenter, 0, 0, 0)
grid_sizer_5.Add(self.label_9, 0, 0, 0)
grid_sizer_5.Add(self.login_vcenter, 0, 0, 0)
grid_sizer_5.Add(self.label_10, 0, 0, 0)
grid_sizer_5.Add(self.passwor_vcenter, 0, 0, 0)
grid_sizer_5.Add(self.label_8, 0, 0, 0)
grid_sizer_5.Add(self.puert_vcenter, 0, 0, 0)
sizer_6.Add(grid_sizer_5, 1, wx.ALIGN_CENTER | wx.ALIGN_RIGHT | wx.ALL | wx.EXPAND, 10)
grid_sizer_6.Add(self.button_Exit, 0, wx.RIGHT, 3)
grid_sizer_6.Add(self.button_Connect, 0, 0, 0)
sizer_6.Add(grid_sizer_6, 1, wx.ALIGN_RIGHT | wx.ALL, 4)
self.SetSizer(sizer_6)
self.Layout()
# end wxGlade
# end of class Dialogo_acceso_vcenter
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
from wx.lib.floatcanvas.ScreenShot import getScreenShotBitmap
note1 = wx.StaticText(self, -1, errorText)
note2 = wx.StaticText(self, -1, "This is what the FloatCanvas can look like:")
S = wx.BoxSizer(wx.VERTICAL)
S.Add((10, 10), 1)
S.Add(note1, 0, wx.ALIGN_CENTER)
S.Add(note2, 0, wx.ALIGN_CENTER | wx.BOTTOM, 4)
S.Add(wx.StaticBitmap(self,-1,getScreenShotBitmap()),0,wx.ALIGN_CENTER)
S.Add((10, 10), 1)
self.SetSizer(S)
self.Layout()
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
note1 = wx.StaticText(self, -1, "The FloatCanvas Demo needs")
note2 = wx.StaticText(self, -1, "a separate frame")
b = wx.Button(self, -1, "Open Demo Frame Now")
b.Bind(wx.EVT_BUTTON, self.OnButton)
S = wx.BoxSizer(wx.VERTICAL)
S.Add((10, 10), 1)
S.Add(note1, 0, wx.ALIGN_CENTER)
S.Add(note2, 0, wx.ALIGN_CENTER | wx.BOTTOM, 5)
S.Add(b, 0, wx.ALIGN_CENTER | wx.ALL, 5)
S.Add((10, 10), 1)
self.SetSizer(S)
self.Layout()
def add_num(self, rang, accu, title, key, unit):
sizer = wx.BoxSizer( wx.HORIZONTAL )
lab_title = wx.StaticText( self, wx.ID_ANY, title,
wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
lab_title.Wrap( -1 )
sizer.Add( lab_title, 0, wx.ALIGN_CENTER|wx.ALL, 5 )
ctrl = NumCtrl(self, rang, accu)
self.ctrl_dic[key] = ctrl
ctrl.Bind(wx.EVT_KEY_UP, lambda x : self.para_changed(key))
sizer.Add( ctrl, 2, wx.ALL, 5 )
lab_unit = wx.StaticText( self, wx.ID_ANY, unit,
wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
lab_unit.Wrap( -1 )
sizer.Add( lab_unit, 0, wx.ALIGN_CENTER|wx.ALL, 5 )
self.tus.append((lab_title, lab_unit))
self.lst.Add( sizer, 0, wx.EXPAND, 5 )
def add_color(self, title, key, unit):
sizer = wx.BoxSizer( wx.HORIZONTAL )
lab_title = wx.StaticText( self, wx.ID_ANY, title,
wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
lab_title.Wrap( -1 )
sizer.Add( lab_title, 0, wx.ALIGN_CENTER|wx.ALL, 5 )
ctrl = ColorCtrl(self)
self.ctrl_dic[key] = ctrl
ctrl.Bind(wx.EVT_KEY_UP, lambda x : self.para_changed(key))
sizer.Add( ctrl, 2, wx.ALL, 5 )
lab_unit = wx.StaticText( self, wx.ID_ANY, unit,
wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
lab_unit.Wrap( -1 )
sizer.Add( lab_unit, 0, wx.ALIGN_CENTER|wx.ALL, 5 )
self.tus.append((lab_title, lab_unit))
self.lst.Add( sizer, 0, wx.EXPAND, 5 )
def add_slide(self, rang, title, key, unit):
sizer = wx.BoxSizer( wx.HORIZONTAL )
lab_title = wx.StaticText( self, wx.ID_ANY, title,
wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
lab_title.Wrap( -1 )
sizer.Add( lab_title, 0, wx.ALIGN_CENTER|wx.ALL, 5 )
iswin = platform.system() == 'Windows'
lab = wx.SL_VALUE_LABEL if iswin else wx.SL_LABELS
ctrl = wx.Slider( self, wx.ID_ANY, 50, rang[0], rang[1],
wx.DefaultPosition, wx.Size( -1,-1 ), wx.SL_HORIZONTAL|lab )
self.ctrl_dic[key] = ctrl
ctrl.Bind(wx.EVT_SCROLL, lambda x : self.para_changed(key))
sizer.Add( ctrl, 2, wx.ALL, 5 )
lab_unit = wx.StaticText( self, wx.ID_ANY, unit,
wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
lab_unit.Wrap( -1 )
sizer.Add( lab_unit, 0, wx.ALIGN_CENTER|wx.ALL, 5 )
self.tus.append((lab_title, lab_unit))
self.lst.Add( sizer, 0, wx.EXPAND, 5 )
def add_txt(self, title, key, unit):
sizer = wx.BoxSizer( wx.HORIZONTAL )
lab_title = wx.StaticText( self, wx.ID_ANY, title,
wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
lab_title.Wrap( -1 )
sizer.Add( lab_title, 0, wx.ALIGN_CENTER|wx.ALL, 5 )
ctrl = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString,
wx.DefaultPosition, wx.DefaultSize, 0 )
self.ctrl_dic[key] = ctrl
ctrl.Bind( wx.EVT_KEY_UP, lambda x : self.para_changed(key))
sizer.Add( ctrl, 2, wx.ALL, 5 )
lab_unit = wx.StaticText( self, wx.ID_ANY, unit,
wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
lab_unit.Wrap( -1 )
sizer.Add( lab_unit, 0, wx.ALIGN_CENTER|wx.ALL, 5 )
self.tus.append((lab_title, lab_unit))
self.lst.Add( sizer, 0, wx.EXPAND, 5 )
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title)
self.selection_idx = None
self.selection_text = None
vbox = wx.BoxSizer(wx.VERTICAL)
stline = wx.StaticText(
self,
11,
'Duplicate Component values found!'
'\n\nPlease select which format to follow:')
vbox.Add(stline, 0, wx.ALIGN_CENTER|wx.TOP)
self.comp_list = wx.ListBox(self, 331, style=wx.LB_SINGLE)
vbox.Add(self.comp_list, 1, wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND)
self.SetSizer(vbox)
self.comp_list.Bind(wx.EVT_LISTBOX_DCLICK, self.on_selection, id=wx.ID_ANY)
def create_spin(**kwargs):
panel = kwargs.get('panel')
value = kwargs.get('value')
key = kwargs.get('key')
bind = kwargs.get('bind')
gui = kwargs.get('gui')
item_sizer = wx.BoxSizer(wx.HORIZONTAL)
item_name = MODULE_KEY.join(key)
style = wx.ALIGN_LEFT
item_box = wx.SpinCtrl(panel, id=id_renew(item_name, update=True), min=gui['min'], max=gui['max'],
initial=int(value), style=style)
item_text = wx.StaticText(panel, label=translate_key(item_name))
item_box.Bind(wx.EVT_SPINCTRL, bind)
item_box.Bind(wx.EVT_TEXT, bind)
item_sizer.Add(item_text, 0, wx.ALIGN_CENTER)
item_sizer.Add(item_box)
return {'item': item_sizer, 'text_size': item_text.GetSize()[0], 'text_ctrl': item_text}
def create_colour_picker(**kwargs):
panel = kwargs.get('panel')
value = kwargs.get('value')
key = kwargs.get('key')
bind = kwargs.get('bind')
item_sizer = wx.BoxSizer(wx.HORIZONTAL)
item_name = MODULE_KEY.join(key)
colour_picker = CustomColourPickerCtrl()
item_box = colour_picker.create(panel, value=value, event=bind, key=key)
item_text = wx.StaticText(panel, label=translate_key(item_name))
item_sizer.Add(item_text, 0, wx.ALIGN_CENTER)
item_sizer.Add(item_box, 1, wx.EXPAND)
return {'item': item_sizer, 'text_size': item_text.GetSize()[0], 'text_ctrl': item_text}
def create_dropdown(**kwargs):
panel = kwargs.get('panel')
value = kwargs.get('value')
key = kwargs.get('key')
bind = kwargs.get('bind')
gui = kwargs.get('gui')
item_sizer = wx.BoxSizer(wx.HORIZONTAL)
choices = gui.get('choices', [])
item_name = MODULE_KEY.join(key)
item_text = wx.StaticText(panel, label=translate_key(item_name))
item_box = KeyChoice(panel, id=id_renew(item_name, update=True),
keys=choices, choices=choices)
item_box.Bind(wx.EVT_CHOICE, bind)
item_box.SetSelection(choices.index(value))
item_sizer.Add(item_text, 0, wx.ALIGN_CENTER)
item_sizer.Add(item_box)
return {'item': item_sizer, 'text_size': item_text.GetSize()[0], 'text_ctrl': item_text}
def __init__(self, parent):
super(MyTitle, self).__init__(parent)
self.SetBackgroundColour('#00b294')
self.SetMinSize((-1, 80))
sizer = wx.BoxSizer()
sizer.AddStretchSpacer()
family = wx.FONTFAMILY_DEFAULT
style = wx.FONTSTYLE_NORMAL
weight = wx.FONTWEIGHT_NORMAL
font = wx.Font(20, family, style, weight)
self.text = wx.StaticText(self, label=TITLE, style=wx.ALIGN_CENTER)
self.text.SetFont(font)
sizer.Add(self.text, flag=wx.ALIGN_CENTER_VERTICAL)
sizer.AddStretchSpacer()
self.SetSizer(sizer)
def GetAttr(self, row, col, kind):
#if _iswxphoenix:
attr = wx.grid.GridCellAttr().Clone()
#else:
# attr = wx.grid.GridCellAttr()
if col >= self.N_COLS:
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
elif col == 0:
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
elif col == 1:
part = self._OM.get(self.partmap[row])
attr.SetBackgroundColour(part.color)
attr.SetReadOnly(True)
elif col == 2:
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
elif col == 3:
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
return attr
def create_data_view_ctrl(self):
dvc = dv.DataViewCtrl(self.splitter, style=dv.DV_ROW_LINES|
dv.DV_VERT_RULES|dv.DV_MULTIPLE
)
UIM = UIManager()
controller = UIM.get(self._controller_uid)
model = controller._get_real_model()
# Track
dv_col = dvc.AppendTextColumn("Track", 0, width=85)
dv_col.SetMinWidth(55)
# Object Type
dvcr_object_tid = ObjectTidRenderer()
dv_col = dv.DataViewColumn("Object Type", dvcr_object_tid, 1, width=85)
dv_col.SetMinWidth(85)
dvc.AppendColumn(dv_col)
# Object Name
dvcr_curve_name = ObjectNameRenderer(model)
dv_col = dv.DataViewColumn("Object Name", dvcr_curve_name, 2, width=130)
dv_col.SetMinWidth(85)
dvc.AppendColumn(dv_col)
# Adjusting
for idx, dv_col in enumerate(dvc.Columns):
dv_col.Renderer.Alignment = wx.ALIGN_CENTER
dv_col.SetAlignment(wx.ALIGN_CENTER)
return dvc
def __init__(self, controller_uid):
TopLevel.__init__(self, controller_uid)
UIM = UIManager()
controller = UIM.get(self._controller_uid)
wx.Dialog.__init__(self, None, wx.ID_ANY, controller.model.title,
pos=controller.model.pos, size=controller.model.size,
style=controller.model.style
)
self._objects = {}
if controller.model.icon:
self.icon = wx.Icon(controller.model.icon, wx.BITMAP_TYPE_ICO)
self.SetIcon(self.icon)
if controller.model.maximized:
self.Maximize()
self.Bind(wx.EVT_MAXIMIZE, self.on_maximize)
self.Bind(wx.EVT_SIZE, self.on_size)
self.Bind(wx.EVT_MOVE, self.on_move)
dialog_box = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(dialog_box)
self.mainpanel = self.AddCreateContainer('BoxSizer', self, proportion=1,
flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.EXPAND, border=10
)
button_sizer = self.CreateButtonSizer(controller.model.flags)
dialog_box.Add(button_sizer, flag=wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, border=10)
dialog_box.Layout()
def GetAttr(self, row, col, kind):
#if _iswxphoenix:
attr = wx.grid.GridCellAttr().Clone()
if col >= self.N_COLS:
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
elif col == 0:
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
elif col == 1:
rocktype = self._OM.get(self.rocktypemap[row])
attr.SetBackgroundColour(rocktype.color)
attr.SetReadOnly(True)
elif col == 2:
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
elif col == 3:
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
return attr
def __init__(self, parent, columns, df_list_ctrl):
wx.Panel.__init__(self, parent)
columns_with_neutral_selection = [''] + list(columns)
self.columns = columns
self.df_list_ctrl = df_list_ctrl
self.figure = Figure(facecolor="white", figsize=(1, 1))
self.axes = self.figure.add_subplot(111)
self.canvas = FigureCanvas(self, -1, self.figure)
chart_toolbar = NavigationToolbar2Wx(self.canvas)
self.combo_box1 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.on_combo_box_select)
row_sizer = wx.BoxSizer(wx.HORIZONTAL)
row_sizer.Add(self.combo_box1, 0, wx.ALL | wx.ALIGN_CENTER, 5)
row_sizer.Add(chart_toolbar, 0, wx.ALL, 5)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.canvas, 1, flag=wx.EXPAND, border=5)
sizer.Add(row_sizer)
self.SetSizer(sizer)
def __init__(self, parent, columns, df_list_ctrl):
wx.Panel.__init__(self, parent)
columns_with_neutral_selection = [''] + list(columns)
self.columns = columns
self.df_list_ctrl = df_list_ctrl
self.figure = Figure(facecolor="white", figsize=(1, 1))
self.axes = self.figure.add_subplot(111)
self.canvas = FigureCanvas(self, -1, self.figure)
chart_toolbar = NavigationToolbar2Wx(self.canvas)
self.combo_box1 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY)
self.combo_box2 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.on_combo_box_select)
row_sizer = wx.BoxSizer(wx.HORIZONTAL)
row_sizer.Add(self.combo_box1, 0, wx.ALL | wx.ALIGN_CENTER, 5)
row_sizer.Add(self.combo_box2, 0, wx.ALL | wx.ALIGN_CENTER, 5)
row_sizer.Add(chart_toolbar, 0, wx.ALL, 5)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.canvas, 1, flag=wx.EXPAND, border=5)
sizer.Add(row_sizer)
self.SetSizer(sizer)
def __init__(self):
frame = wx.Frame.__init__(self, None, -1, u"????", pos=(200, 300), size=(300, 150), style=wx.MINIMIZE_BOX |
wx.RESIZE_BORDER | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN)
self.panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
self.labelResult = wx.StaticText(
self.panel, -1, u"????/??????", size=(300, 150),style=wx.ALIGN_CENTER)
sizer.Add(self.labelResult, wx.EXPAND)
self.panel.SetSizer(sizer)
self.labelResult.SetDropTarget(OnDropFile(self.labelResult))
def InitUI(self):
sb = wx.StaticText(self, label='Stop! Open or Create new project first!')
ic = wx.ArtProvider.GetBitmap( wx.ART_TIP, size=(48,48) )
icn= wx.StaticBitmap(self,-1,ic,name='Stop')
lbl_mt = wx.StaticText(self, label="")
vbox = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(vbox)
vbox.Add(lbl_mt,flag=wx.CENTER, border=2)
vbox.Add(sb,flag=wx.CENTER, border=2)
vbox.Add(icn,flag=wx.CENTER, border=0)
hbox2 = wx.BoxSizer(wx.HORIZONTAL)
OButton = wx.Button(self, label='Open')
NButton = wx.Button(self, label='New')
hbox2.Add(OButton, flag=wx.CENTER, border=2)
hbox2.Add(NButton, flag=wx.LEFT, border=5)
vbox.Add(hbox2,flag=wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, border=2)
OButton.Bind(wx.EVT_BUTTON,self.OpenBtn)
NButton.Bind(wx.EVT_BUTTON,self.NewBtn)
self.Show()
self.SetFocus()
self.SetWindowStyle( wx.STAY_ON_TOP )
def __init__(self, parent, name):
wxskinDialog.__init__(self, parent, -1, "Phonebook import")
self.SetAutoLayout(True)
self.function = 0
# Main window resizer object
border = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self, -1, "Name '%s' already exists in SIM phonebook.\n\nDo you want to overwrite exisiting, duplicate or skip!?" % (name))
border.Add(label, 1, wx.ALL, 10)
buttons = wx.BoxSizer(wx.HORIZONTAL)
buttons.Add(wx.Button(self, ID_BUTTON_OVERWRITE, "Overwrite"), 1, wx.ALIGN_LEFT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_COPY, "Duplicate"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_SKIP, "Skip"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
border.Add(buttons, 1, wx.ALL)
self.applyAll = wx.CheckBox(self, ID_CHECKBOX_APPLY_ALL, " Apply to all", wx.Point(65, 40), wx.Size(150, 20), wx.NO_BORDER)
border.Add(self.applyAll, 1, wx.ALIGN_CENTER | wx.ALL)
wx.EVT_BUTTON(self, ID_BUTTON_OVERWRITE, self.onOverwrite)
wx.EVT_BUTTON(self, ID_BUTTON_COPY, self.onDuplicate)
wx.EVT_BUTTON(self, ID_BUTTON_SKIP, self.onSkip)
self.SetAutoLayout(1);
self.SetSizer(border)
border.Fit(self)
self.Layout()
def __init__(self, parent, name):
wxskinDialog.__init__(self, parent, -1, "Phonebook import")
self.SetAutoLayout(True)
self.function = 0
# Main window resizer object
border = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self, -1, "Name '%s' already exists in SIM phonebook.\n\nDo you want to overwrite exisiting, duplicate or skip!?" % (name))
border.Add(label, 1, wx.ALL, 10)
buttons = wx.BoxSizer(wx.HORIZONTAL)
buttons.Add(wx.Button(self, ID_BUTTON_OVERWRITE, "Overwrite"), 1, wx.ALIGN_LEFT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_COPY, "Duplicate"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_SKIP, "Skip"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
border.Add(buttons, 1, wx.ALL)
self.applyAll = wx.CheckBox(self, ID_CHECKBOX_APPLY_ALL, " Apply to all", wx.Point(65, 40), wx.Size(150, 20), wx.NO_BORDER)
border.Add(self.applyAll, 1, wx.ALIGN_CENTER | wx.ALL)
wx.EVT_BUTTON(self, ID_BUTTON_OVERWRITE, self.onOverwrite)
wx.EVT_BUTTON(self, ID_BUTTON_COPY, self.onDuplicate)
wx.EVT_BUTTON(self, ID_BUTTON_SKIP, self.onSkip)
self.SetAutoLayout(1);
self.SetSizer(border)
border.Fit(self)
self.Layout()
def __init__(self, parent, date, number):
wxskinDialog.__init__(self, parent, -1, "SMS import")
self.SetAutoLayout(False)
self.function = 0
# Main window resizer object
border = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self, -1, "SMS from '%s' on '%s' already exists in SMS folder.\n\nDo you want to overwrite exisiting, duplicate or skip!?" % (number, date))
border.Add(label, 1, wx.ALL, 10)
buttons = wx.BoxSizer(wx.HORIZONTAL)
buttons.Add(wx.Button(self, ID_BUTTON_OVERWRITE, "Overwrite"), 1, wx.ALIGN_LEFT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_COPY, "Duplicate"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_SKIP, "Skip"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
border.Add(buttons, 1, wx.ALL)
self.applyAll = wx.CheckBox(self, ID_CHECKBOX_APPLY_ALL, " Apply to all", wx.Point(65, 40), wx.Size(150, 20), wx.NO_BORDER)
border.Add(self.applyAll, 1, wx.ALIGN_CENTER | wx.ALL)
wx.EVT_BUTTON(self, ID_BUTTON_OVERWRITE, self.onOverwrite)
wx.EVT_BUTTON(self, ID_BUTTON_COPY, self.onDuplicate)
wx.EVT_BUTTON(self, ID_BUTTON_SKIP, self.onSkip)
#EVT_CHECKBOX(self, ID_CHECKBOX_APPLY_ALL, self.EvtCheckBox)
self.SetAutoLayout(1);
self.SetSizer(border)
border.Fit(self)
self.Layout()
def _prepare_for_automatic_upload(self):
"""Clear out anything else that happens to be on the panel before Starting
an automatic upload."""
self.Freeze()
self._sizer.Clear(deleteWindows=True)
self._discovered_runs = []
self._run_sizer = wx.BoxSizer(wx.VERTICAL)
self._upload_sizer = wx.BoxSizer(wx.HORIZONTAL)
self._sizer.Add(self._run_sizer, proportion=1, flag=wx.EXPAND)
self._sizer.Add(self._upload_sizer, proportion=0, flag=wx.ALIGN_CENTER)
self.Layout()
self.Thaw()
def _settings_changed(self, api=None):
"""Reset the main display and attempt to connect to the server
whenever the connection settings may have changed.
Args:
api: A placeholder for a complete api that's passed when the event is fired.
"""
# before doing anything, clear all of the children from the sizer and
# also delete any windows attached (Buttons and stuff extend from Window!)
self._sizer.Clear(deleteWindows=True)
# and clear out the list of discovered runs that we might be uploading to the server.
self._discovered_runs = []
# initialize the invalid sheets panel so that it can listen for events
# before directory scanning starts, but hide it until we actually get
# an error raised by the validation part.
self._invalid_sheets_panel = InvalidSampleSheetsPanel(self, self._get_default_directory())
self._invalid_sheets_panel.Hide()
should_monitor_directory = read_config_option("monitor_default_dir", expected_type=bool, default_value=False)
if should_monitor_directory:
automatic_upload_status_sizer = wx.BoxSizer(wx.HORIZONTAL)
auto_upload_enabled_text = wx.StaticText(self, label=u"? Automatic upload enabled.")
auto_upload_enabled_text.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD))
auto_upload_enabled_text.SetForegroundColour(wx.Colour(51, 102, 255))
auto_upload_enabled_text.SetToolTipString("Monitoring {} for CompletedJobInfo.xml".format(self._get_default_directory()))
self._sizer.Add(auto_upload_enabled_text, flag=wx.ALIGN_CENTER | wx.ALL, border=5)
logging.info("Going to monitor default directory [{}] for new runs.".format(self._get_default_directory()))
# topics to handle when monitoring a directory for automatic upload
pub.subscribe(self._prepare_for_automatic_upload, DirectoryMonitorTopics.new_run_observed)
pub.subscribe(self._start_upload, DirectoryMonitorTopics.finished_discovering_run)
threading.Thread(target=monitor_directory, kwargs={"directory": self._get_default_directory()}).start()
# run connecting in a different thread so we don't freeze up the GUI
threading.Thread(target=self._connect_to_irida).start()