def __init__(self, parent, root): wx.Panel.__init__(self, parent) self.root = root # Name self.name = wx.StaticText(self, -1, '(No file loaded)') self.font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD) self.name.SetFont(self.font) # Load button self.load = wx.Button(self, wx.ID_OPEN, "Load") self.copy = wx.Button(self, wx.ID_COPY, "Copy") self.copy.Disable() # Anim List self.anim_list = wx.ListCtrl(self, style=wx.LC_REPORT) self.anim_list.InsertColumn(0, "#", width=30) self.anim_list.InsertColumn(1, "Animation", width=200) self.anim_list.InsertColumn(2, "Frames", width=50) self.anim_list.InsertColumn(3, "Copied", width=60) self.anim_list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.on_right_click) self.anim_list.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_select) self.anim_list.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.on_select) self.anim_list.SetDropTarget(FileDropTarget(self, "load_side_file")) # Bind self.Bind(wx.EVT_BUTTON, self.on_open, id=wx.ID_OPEN) self.Bind(wx.EVT_BUTTON, self.on_copy, id=wx.ID_COPY) # Select All self.Bind(wx.EVT_MENU, self.select_all, id=wx.ID_SELECTALL) self.Bind(wx.EVT_MENU, self.on_copy, id=wx.ID_COPY) accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('a'), wx.ID_SELECTALL), (wx.ACCEL_CTRL, ord('c'), wx.ID_COPY), ]) self.anim_list.SetAcceleratorTable(accelerator_table) # Button Sizer self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) self.button_sizer.Add(self.load) self.button_sizer.AddSpacer(5) self.button_sizer.Add(self.copy) # Use some sizers to see layout options self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.name, 0, wx.CENTER) self.sizer.Add(self.button_sizer) self.sizer.Add(self.anim_list, 1, wx.EXPAND | wx.ALL) # Layout sizers self.SetSizer(self.sizer) self.SetAutoLayout(1)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.code = '' self.bac = None self.bdm = None self.ean = None self.cam_ean = None self.parent = parent self.dirname = '' # Name self.name = wx.StaticText(self, -1, '(No file loaded)') self.font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD) self.name.SetFont(self.font) # Buttons self.open = wx.Button(self, wx.ID_OPEN, "Load") self.copy = wx.Button(self, wx.ID_COPY, "Copy") self.copy.Disable() # Entry List self.entry_list = TreeListCtrl(self, style=TL_MULTIPLE) self.entry_list.AppendColumn("BAC Entry") self.entry_list.AppendColumn("Copied", width=64) self.entry_list.Bind(EVT_TREELIST_ITEM_CONTEXT_MENU, self.on_right_click) # self.cdo = wx.CustomDataObject("BDMEntry") self.Bind(wx.EVT_BUTTON, self.on_open, id=wx.ID_OPEN) self.Bind(wx.EVT_BUTTON, self.on_copy, id=wx.ID_COPY) self.Bind(wx.EVT_MENU, self.on_copy, id=wx.ID_COPY) accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('c'), wx.ID_COPY), ]) self.entry_list.SetAcceleratorTable(accelerator_table) self.SetDropTarget(FileDropTarget(self, "load_side_moveset")) # Button Sizer button_sizer = wx.BoxSizer(wx.HORIZONTAL) button_sizer.Add(self.open) button_sizer.AddSpacer(5) button_sizer.Add(self.copy) # Use some sizers to see layout options sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.name, 0, wx.CENTER) sizer.Add(button_sizer) sizer.Add(self.entry_list, 1, wx.ALL | wx.EXPAND, 10) # Layout sizers self.SetSizer(sizer) self.SetAutoLayout(1)
def __init__(self, parent, name): wx.Panel.__init__(self, parent) self.parent = parent self.focus = None self.name = name self.reindex_name = f"reindex_{name.replace(' ', '_').lower()}" self.entry_list = wx.TreeCtrl(self, style=wx.TR_MULTIPLE | wx.TR_HAS_BUTTONS | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_LINES_AT_ROOT | wx.TR_HIDE_ROOT) self.entry_list.Bind(wx.EVT_TREE_ITEM_MENU, self.on_right_click) self.entry_list.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_select) self.entry_list.SetDropTarget(FileDropTarget(self, "load_bcs")) self.cdo = None self.paste_data = None self.paste_data_type = None self.paste_data_actual_type = None self.Bind(wx.EVT_MENU, self.on_open, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.on_save, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU, self.on_delete, id=wx.ID_DELETE) self.Bind(wx.EVT_MENU, self.on_copy, id=wx.ID_COPY) self.Bind(wx.EVT_MENU, self.on_paste, id=wx.ID_PASTE) self.Bind(wx.EVT_MENU, self.on_select_all, id=wx.ID_SELECTALL) accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('a'), wx.ID_SELECTALL), (wx.ACCEL_CTRL, ord('c'), wx.ID_COPY), (wx.ACCEL_CTRL, ord('v'), wx.ID_PASTE), (wx.ACCEL_NORMAL, wx.WXK_DELETE, wx.ID_DELETE), ]) self.entry_list.SetAcceleratorTable(accelerator_table) sizer = wx.BoxSizer() sizer.Add(self.entry_list, 1, wx.ALL | wx.EXPAND) pub.subscribe(self.on_select, 'on_select') pub.subscribe(self.set_focus, 'set_focus') pub.subscribe(self.clear_focus, 'clear_focus') self.SetSizer(sizer) self.SetAutoLayout(1)
def __init__(self, parent, title, dirname, filename): sys.excepthook = self.exception_hook self.dirname = '' self.locale = wx.Locale(wx.LANGUAGE_ENGLISH) # A "-1" in the size parameter instructs wxWidgets to use the default size. # In this case, we select 200px width and the default height. wx.Frame.__init__(self, parent, title=title, size=(1300, 950)) self.statusbar = self.CreateStatusBar( ) # A Statusbar in the bottom of the window # Panels self.main_panel = MainPanel(self) self.entry_panel = EntryPanel(self) # Setting up the menu. file_menu = wx.Menu() file_menu.Append(wx.ID_OPEN) file_menu.Append(wx.ID_SAVE) file_menu.Append(wx.ID_CONVERT, "Convert for Skill Creator") file_menu.Append(wx.ID_ABOUT) file_menu.Append(wx.ID_EXIT) edit_menu = wx.Menu() edit_menu.Append(wx.ID_FIND) edit_menu.Append(wx.ID_REPLACE) # Creating the menubar. menu_bar = wx.MenuBar() menu_bar.Append(file_menu, "&File") # Adding the "filemenu" to the MenuBar menu_bar.Append(edit_menu, "&Edit") self.SetMenuBar(menu_bar) # Adding the MenuBar to the Frame content. # Publisher pub.subscribe(self.open_bdm, 'open_bdm') pub.subscribe(self.load_bdm, 'load_bdm') pub.subscribe(self.save_bdm, 'save_bdm') pub.subscribe(self.set_status_bar, 'set_status_bar') # Events. self.Bind(wx.EVT_MENU, self.open_bdm, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.save_bdm, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU, self.on_find, id=wx.ID_FIND) self.Bind(wx.EVT_MENU, self.on_replace, id=wx.ID_REPLACE) self.Bind(wx.EVT_MENU, self.on_convert, id=wx.ID_CONVERT) self.Bind(wx.EVT_MENU, self.on_about, id=wx.ID_ABOUT) self.Bind(wx.EVT_MENU, self.on_exit, id=wx.ID_EXIT) self.Bind(wx.EVT_MENU, self.main_panel.on_add, id=wx.ID_ADD) self.Bind(wx.EVT_MENU, self.main_panel.on_new, id=wx.ID_NEW) self.Bind(wx.EVT_MENU, self.main_panel.on_delete, id=wx.ID_DELETE) self.Bind(wx.EVT_MENU, self.main_panel.on_copy, id=wx.ID_COPY) self.Bind(wx.EVT_MENU, self.main_panel.on_paste, id=wx.ID_PASTE) accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('n'), wx.ID_NEW), (wx.ACCEL_CTRL, ord('o'), wx.ID_OPEN), (wx.ACCEL_CTRL, ord('s'), wx.ID_SAVE), (wx.ACCEL_CTRL, ord('f'), wx.ID_FIND), (wx.ACCEL_CTRL, ord('h'), wx.ID_REPLACE), ]) self.SetAcceleratorTable(accelerator_table) self.SetDropTarget(FileDropTarget(self, "load_bdm")) # Name self.name = wx.StaticText(self, -1, '(No file loaded)') font = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD) self.name.SetFont(font) # Buttons open_button = wx.Button(self, wx.ID_OPEN, "Load") open_button.Bind(wx.EVT_BUTTON, self.open_bdm) save_button = wx.Button(self, wx.ID_SAVE, "Save") save_button.Bind(wx.EVT_BUTTON, self.save_bdm) hyperlink = HyperLinkCtrl( self, -1, "What do all these things mean?", URL="https://docs.google.com/document/d/" "18gaAbNCeJyTgizz5IvvXzjWcH9K5Q1wvUHTeWnp8M-E/edit#heading=h.tx82dphejin1" ) # Sizer sizer = wx.BoxSizer(wx.VERTICAL) button_sizer = wx.BoxSizer() button_sizer.Add(open_button) button_sizer.AddSpacer(10) button_sizer.Add(save_button) button_sizer.Add(hyperlink, 0, wx.ALL, 10) panel_sizer = wx.BoxSizer() panel_sizer.Add(self.main_panel, 1, wx.ALL | wx.EXPAND) panel_sizer.Add(self.entry_panel, 3, wx.ALL | wx.EXPAND) sizer.Add(self.name, 0, wx.CENTER) sizer.Add(button_sizer, 0, wx.ALL, 10) sizer.Add(panel_sizer, 1, wx.ALL | wx.EXPAND) self.SetBackgroundColour('white') self.SetSizer(sizer) self.SetAutoLayout(1) # Lists self.entry_list = self.main_panel.entry_list # Dialogs self.find = FindDialog(self, self.entry_list, self.entry_panel, -1) self.replace = ReplaceDialog(self, self.entry_list, self.entry_panel, -1) sizer.Layout() self.Show() if filename: self.load_bdm(dirname, filename)
def __init__(self, parent, root, filetype): wx.Panel.__init__(self, parent) self.root = root self.filetype = filetype self.selected = [] # Name self.name = wx.StaticText(self, -1, '(No file loaded)') self.font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD) self.name.SetFont(self.font) # Buttons self.load = wx.Button(self, wx.ID_OPEN, "Load") self.copy = wx.Button(self, wx.ID_COPY, "Copy") self.info = wx.Button(self, wx.ID_INFO, "Info") self.copy.Disable() self.info.Disable() # Children self.check_box = wx.CheckBox(self, -1, "Select child bones?") self.check_box.SetValue(wx.CHK_CHECKED) self.bone_list = wx.dataview.TreeListCtrl(self) self.bone_list.AppendColumn("Bone") self.bone_list.AppendColumn("Selected", width=80) self.bone_list.Bind(wx.dataview.EVT_TREELIST_ITEM_CONTEXT_MENU, self.on_right_click) self.bone_list.Bind(wx.dataview.EVT_TREELIST_SELECTION_CHANGED, self.on_select) self.bone_list.SetDropTarget(FileDropTarget(self, "load_side_file")) self.Bind(wx.EVT_BUTTON, self.on_open, id=wx.ID_OPEN) self.Bind(wx.EVT_BUTTON, self.on_copy, id=wx.ID_COPY) self.Bind(wx.EVT_BUTTON, self.on_info, id=wx.ID_INFO) self.Bind(wx.EVT_MENU, self.on_copy, id=wx.ID_COPY) self.Bind(wx.EVT_MENU, self.on_info, id=wx.ID_INFO) accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('c'), wx.ID_COPY), (wx.ACCEL_CTRL, ord('i'), wx.ID_INFO) ]) self.bone_list.SetAcceleratorTable(accelerator_table) # Use some sizers to see layout options self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) self.button_sizer.Add(self.load) self.button_sizer.AddSpacer(5) self.button_sizer.Add(self.copy) self.button_sizer.AddSpacer(5) self.button_sizer.Add(self.info) self.button_sizer.AddSpacer(10) self.button_sizer.Add(self.check_box) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.name, 0, wx.CENTER) self.sizer.Add(self.button_sizer) self.sizer.Add(self.bone_list, 1, wx.EXPAND) pub.subscribe(self.deselect_all, 'deselect_bones') # Layout sizers self.SetSizer(self.sizer) self.SetAutoLayout(1)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.code = '' self.bac = None self.bdm = None self.ean = None self.cam_ean = None self.dirname = '' self.parent = parent self.links = defaultdict( lambda: defaultdict(lambda: defaultdict(dict))) # Name self.name = wx.StaticText(self, -1, '(No file loaded)') self.font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD) self.name.SetFont(self.font) # Buttons self.open = wx.Button(self, wx.ID_OPEN, "Load") self.save = wx.Button(self, wx.ID_SAVE, "Save") self.save.Disable() self.paste = wx.Button(self, wx.ID_PASTE, "Paste") self.paste.Disable() self.add = wx.Button(self, wx.ID_ADD, "Add Copy") self.add.Disable() # Entry List self.entry_list = TreeListCtrl(self, style=TL_MULTIPLE) self.entry_list.AppendColumn("BAC Entry") self.entry_list.Bind(EVT_TREELIST_ITEM_CONTEXT_MENU, self.on_right_click) # Bind self.Bind(wx.EVT_BUTTON, self.on_open, id=wx.ID_OPEN) self.Bind(wx.EVT_BUTTON, self.on_save, id=wx.ID_SAVE) self.Bind(wx.EVT_BUTTON, self.on_paste, id=wx.ID_PASTE) self.Bind(wx.EVT_BUTTON, self.on_add, id=wx.ID_ADD) self.Bind(wx.EVT_MENU, self.on_paste, id=wx.ID_PASTE) accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('v'), wx.ID_PASTE), ]) self.entry_list.SetAcceleratorTable(accelerator_table) self.SetDropTarget(FileDropTarget(self, "load_main_moveset")) # Button Sizer button_sizer = wx.BoxSizer(wx.HORIZONTAL) button_sizer.Add(self.open) button_sizer.AddSpacer(5) button_sizer.Add(self.save) button_sizer.AddSpacer(5) button_sizer.Add(self.paste) button_sizer.AddSpacer(5) button_sizer.Add(self.add) # Use some sizers to see layout options sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.name, 0, wx.CENTER) sizer.Add(button_sizer) sizer.Add(self.entry_list, 1, wx.ALL | wx.EXPAND, 10) # Layout sizers self.SetSizer(sizer) self.SetAutoLayout(1)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent self.focus = None self.bac = None self.cdo = None self.refresh = True self.entry_list = wx.TreeCtrl(self, style=wx.TR_MULTIPLE | wx.TR_HAS_BUTTONS | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_LINES_AT_ROOT | wx.TR_HIDE_ROOT) self.entry_list.SetDropTarget(FileDropTarget(self, "load_bac")) self.entry_list.Bind(wx.EVT_TREE_ITEM_MENU, self.on_right_click) self.entry_list.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_select) self.cdo = wx.CustomDataObject("BACEntry") self.append_id = wx.NewId() self.insert_id = wx.NewId() self.add_copy_id = wx.NewId() self.insert_copy_id = wx.NewId() self.offset_id = wx.NewId() self.inc_offset_id = wx.NewId() self.Bind(wx.EVT_MENU, self.on_open, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.on_save, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU, self.on_delete, id=wx.ID_DELETE) self.Bind(wx.EVT_MENU, self.on_copy, id=wx.ID_COPY) self.Bind(wx.EVT_MENU, self.on_paste, id=wx.ID_PASTE) self.Bind(wx.EVT_MENU, self.on_add_copy, id=wx.ID_ADD) self.Bind(wx.EVT_MENU, self.on_append_bac_entry, id=self.append_id) self.Bind(wx.EVT_MENU, self.on_insert_bac_entry, id=self.insert_id) self.Bind(wx.EVT_MENU, partial(self.on_add_copy, append=True), id=self.add_copy_id) self.Bind(wx.EVT_MENU, partial(self.on_add_copy, append=False), id=self.insert_copy_id) self.Bind(wx.EVT_MENU, self.on_offset, id=self.offset_id) self.Bind(wx.EVT_MENU, self.on_offset_inc, id=self.inc_offset_id) accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('c'), wx.ID_COPY), (wx.ACCEL_CTRL, ord('b'), self.offset_id), (wx.ACCEL_CTRL, ord('n'), self.inc_offset_id), (wx.ACCEL_CTRL, ord('v'), wx.ID_PASTE), (wx.ACCEL_CTRL, ord('a'), self.add_copy_id), (wx.ACCEL_NORMAL, wx.WXK_DELETE, wx.ID_DELETE), ]) self.entry_list.SetAcceleratorTable(accelerator_table) # Publishers pub.subscribe(self.convert_for_skill_creator, 'convert_for_skill_creator') pub.subscribe(self.update_entry, 'update_entry') pub.subscribe(self.update_item, 'update_item') pub.subscribe(self.on_select, 'on_select') pub.subscribe(self.reindex, 'reindex') pub.subscribe(self.set_focus, 'set_focus') pub.subscribe(self.clear_focus, 'clear_focus') # Use some sizers to see layout options sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.entry_list, 1, wx.ALL | wx.EXPAND, 10) # Layout sizers self.SetSizer(sizer) self.SetAutoLayout(1)
def __init__(self, parent, root): wx.Panel.__init__(self, parent) self.parent = parent.GetParent().GetParent() self.root = root self.copied_animations = None self.is_camera = False # Name self.name = wx.StaticText(self, -1, '(No file loaded)') self.font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD) self.name.SetFont(self.font) # Buttons self.open = wx.Button(self, wx.ID_OPEN, "Load") self.save = wx.Button(self, wx.ID_SAVE, "Save") self.edit = wx.Button(self, wx.ID_EDIT, "Edit") # AnimList self.anim_list = wx.ListCtrl(self, style=wx.LC_REPORT) self.anim_list.InsertColumn(0, "#", width=30) self.anim_list.InsertColumn(1, "Animation", width=200) self.anim_list.InsertColumn(2, "Frames", width=50) self.anim_list.SetDropTarget(FileDropTarget(self, "load_main_file")) self.anim_list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.on_right_click) # Bind self.Bind(wx.EVT_BUTTON, self.on_open, id=wx.ID_OPEN) self.Bind(wx.EVT_BUTTON, self.on_save, id=wx.ID_SAVE) self.Bind(wx.EVT_BUTTON, self.on_right_click, id=wx.ID_EDIT) # Select All self.insert_id = wx.NewId() self.append_id = wx.NewId() self.rename_id = wx.NewId() self.duration_id = wx.NewId() self.offset_id = wx.NewId() self.rotation_id = wx.NewId() self.scale_id = wx.NewId() self.trim_anim_id = wx.NewId() self.mirror_anim_id = wx.NewId() self.reverse_anim_id = wx.NewId() self.remove_keyframes_id = wx.NewId() self.target_camera_offset_id = wx.NewId() self.Bind(wx.EVT_MENU, self.on_open, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.on_save, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU, self.select_all, id=wx.ID_SELECTALL) self.Bind(wx.EVT_MENU, self.on_delete, id=wx.ID_DELETE) self.Bind(wx.EVT_MENU, self.on_insert, id=self.insert_id) self.Bind(wx.EVT_MENU, self.on_append, id=self.append_id) self.Bind(wx.EVT_MENU, self.on_paste, id=wx.ID_PASTE) self.Bind(wx.EVT_MENU, self.on_rename, id=self.rename_id) self.Bind(wx.EVT_MENU, self.on_set_duration, id=self.duration_id) self.Bind(wx.EVT_MENU, self.on_set_offset, id=self.offset_id) self.Bind(wx.EVT_MENU, self.on_set_rotation, id=self.rotation_id) self.Bind(wx.EVT_MENU, self.on_set_scale, id=self.scale_id) self.Bind(wx.EVT_MENU, self.on_trim_anim, id=self.trim_anim_id) self.Bind(wx.EVT_MENU, self.on_mirror_anim, id=self.mirror_anim_id) self.Bind(wx.EVT_MENU, self.on_reverse_anim, id=self.reverse_anim_id) self.Bind(wx.EVT_MENU, self.on_remove_keyframes, id=self.remove_keyframes_id) self.Bind(wx.EVT_MENU, self.on_set_target_camera_offset, id=self.target_camera_offset_id) accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('a'), wx.ID_SELECTALL), (wx.ACCEL_CTRL, ord('v'), wx.ID_PASTE), (wx.ACCEL_NORMAL, wx.WXK_DELETE, wx.ID_DELETE), (wx.ACCEL_NORMAL, wx.WXK_F2, self.rename_id) ]) self.anim_list.SetAcceleratorTable(accelerator_table) pub.subscribe(self.copy_animation, 'copy_animation') # Button Sizer self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) self.button_sizer.Add(self.open) self.button_sizer.AddSpacer(5) self.button_sizer.Add(self.save) self.button_sizer.AddSpacer(5) self.button_sizer.Add(self.edit) # Use some sizers to see layout options self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.name, 0, wx.CENTER) self.sizer.Add(self.button_sizer) self.sizer.Add(self.anim_list, 1, wx.EXPAND) # Layout sizers self.SetSizer(self.sizer) self.SetAutoLayout(1)
def __init__(self, parent, title, dirname, filename): sys.excepthook = self.exception_hook self.dirname = '' self.bcs = None self.locale = wx.Locale(wx.LANGUAGE_ENGLISH) # A "-1" in the size parameter instructs wxWidgets to use the default size. # In this case, we select 200px width and the default height. wx.Frame.__init__(self, parent, title=title, size=(1300, 900)) self.statusbar = self.CreateStatusBar( ) # A Statusbar in the bottom of the window # Panels self.main_panel = MainPanel(self) self.side_panel = SidePanel(self) # Setting up the menu. file_menu = wx.Menu() file_menu.Append(wx.ID_OPEN) file_menu.Append(wx.ID_SAVE) file_menu.Append(wx.ID_ABOUT) file_menu.Append(wx.ID_EXIT) edit_menu = wx.Menu() edit_menu.Append(wx.ID_FIND) edit_menu.Append(wx.ID_REPLACE) # Creating the menubar. menu_bar = wx.MenuBar() menu_bar.Append(file_menu, "&File") # Adding the "filemenu" to the MenuBar menu_bar.Append(edit_menu, "&Edit") self.SetMenuBar(menu_bar) # Adding the MenuBar to the Frame content. # Publisher pub.subscribe(self.open_bcs, 'open_bcs') pub.subscribe(self.load_bcs, 'load_bcs') pub.subscribe(self.save_bcs, 'save_bcs') pub.subscribe(self.load_part_sets, 'load_part_sets') pub.subscribe(self.load_parts, 'load_parts') pub.subscribe(self.load_color_selectors, 'load_color_selectors') pub.subscribe(self.load_physics, 'load_physics') pub.subscribe(self.load_part_colors, 'load_part_colors') pub.subscribe(self.load_colors, 'load_colors') pub.subscribe(self.load_bodies, 'load_bodies') pub.subscribe(self.load_bone_scales, 'load_bone_scales') pub.subscribe(self.load_skeletons, 'load_skeletons') pub.subscribe(self.load_bones, 'load_bones') pub.subscribe(self.set_status_bar, 'set_status_bar') pub.subscribe(self.reindex_part_sets, 'reindex_part_sets') pub.subscribe(self.reindex_part_colors, 'reindex_part_colors') pub.subscribe(self.reindex_bodies, 'reindex_bodies') pub.subscribe(self.reindex_skeletons, 'reindex_skeletons') pub.subscribe(self.change_add_text, 'change_add_text') pub.subscribe(self.enable_add_copy, 'enable_add_copy') # Events. self.Bind(wx.EVT_MENU, self.open_bcs, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.save_bcs, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU, self.on_find, id=wx.ID_FIND) self.Bind(wx.EVT_MENU, self.on_replace, id=wx.ID_REPLACE) self.Bind(wx.EVT_MENU, self.on_about, id=wx.ID_ABOUT) self.Bind(wx.EVT_MENU, self.on_exit, id=wx.ID_EXIT) accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('o'), wx.ID_OPEN), (wx.ACCEL_CTRL, ord('s'), wx.ID_SAVE), (wx.ACCEL_CTRL, ord('f'), wx.ID_FIND), (wx.ACCEL_CTRL, ord('h'), wx.ID_REPLACE), ]) self.SetAcceleratorTable(accelerator_table) self.SetDropTarget(FileDropTarget(self, "load_bcs")) # Name self.name = wx.StaticText(self, -1, '(No file loaded)') font = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD) self.name.SetFont(font) # Buttons open_button = wx.Button(self, wx.ID_OPEN, "Load", size=(80, -1)) open_button.Bind(wx.EVT_BUTTON, self.open_bcs) self.save_button = wx.Button(self, wx.ID_SAVE, "Save", size=(80, -1)) self.save_button.Disable() self.save_button.Bind(wx.EVT_BUTTON, self.save_bcs) self.add_button = wx.Button(self, wx.ID_ADD, "Add Part Set", size=(100, -1)) self.add_button.Disable() self.add_button.Bind(wx.EVT_BUTTON, self.on_add) self.add_copy_button = wx.Button(self, wx.ID_ADD, "Add Part Set Copy", size=(120, -1)) self.add_copy_button.Disable() self.add_copy_button.Bind(wx.EVT_BUTTON, partial(self.on_add, paste=True)) hyperlink = HyperLinkCtrl( self, -1, "What do all these things mean?", URL="https://docs.google.com/document/d/" "1df8_Zs3g0YindDNees_CSrWVpMBtwWGrFf2FE8JruUk/edit?usp=sharing") # Race/Gender self.gender = wx.ComboBox(self, choices=["Male", "Female"], style=wx.CB_READONLY, size=(80, -1)) self.gender.Disable() self.race = wx.ComboBox(self, choices=[ "Human", "Saiyan", "Namekian", "Frieza", "Majin", "Android (?)" ], style=wx.CB_READONLY, size=(80, -1)) self.race.Disable() # Sizer sizer = wx.BoxSizer(wx.VERTICAL) button_sizer = wx.BoxSizer() button_sizer.Add(open_button, 0, wx.LEFT, 10) button_sizer.Add(self.save_button, 0, wx.LEFT, 10) button_sizer.Add(self.add_button, 0, wx.LEFT, 10) button_sizer.Add(self.add_copy_button, 0, wx.LEFT, 10) button_sizer.Add(hyperlink, 0, wx.LEFT | wx.BOTTOM, 10) header_sizer = wx.BoxSizer() header_sizer.Add(self.gender, 0, wx.LEFT, 10) header_sizer.Add(self.race, 0, wx.LEFT, 10) panel_sizer = wx.BoxSizer() panel_sizer.Add(self.main_panel, 1, wx.ALL | wx.EXPAND) panel_sizer.Add(self.side_panel, 2, wx.ALL | wx.EXPAND) sizer.Add(self.name, 0, wx.CENTER) sizer.Add(button_sizer, 0, wx.ALL) sizer.Add(header_sizer, 0, wx.TOP, 10) sizer.Add(panel_sizer, 1, wx.ALL | wx.EXPAND) self.SetBackgroundColour('white') self.SetSizer(sizer) self.SetAutoLayout(1) # Lists self.part_set_list = self.main_panel.pages["Part Sets"].entry_list self.part_color_list = self.main_panel.pages["Part Colors"].entry_list self.body_list = self.main_panel.pages["Bodies"].entry_list self.skeleton_list = self.main_panel.pages["Skeletons"].entry_list color_db.image_list = wx.ImageList(16, 16) self.part_set_list.SetImageList(color_db.image_list) self.part_color_list.SetImageList(color_db.image_list) # Dialogs self.find = FindDialog(self, self.main_panel) self.replace = ReplaceDialog(self, self.main_panel) sizer.Layout() self.Show() if filename: self.load_bcs(dirname, filename)
def __init__(self, parent, root, filetype): wx.Panel.__init__(self, parent) self.root = root self.filetype = filetype self.copied_bones = None if self.filetype == 'EAN': style = wx.dataview.TL_CHECKBOX | wx.dataview.TL_MULTIPLE | wx.dataview.TL_3STATE else: style = wx.dataview.TL_MULTIPLE # Name self.name = wx.StaticText(self, -1, '(No file loaded)') self.font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD) self.name.SetFont(self.font) # Buttons self.open = wx.Button(self, wx.ID_OPEN, "Load") self.save = wx.Button(self, wx.ID_SAVE, "Save") self.edit = wx.Button(self, wx.ID_EDIT, "Edit") self.info = wx.Button(self, wx.ID_INFO, "Info") self.info.SetToolTip(wx.ToolTip("Get current pyxenoverse info")) self.info.Disable() self.bone_list = wx.dataview.TreeListCtrl(self, style=style) self.bone_list.AppendColumn("Bone") self.bone_list.Bind(wx.dataview.EVT_TREELIST_ITEM_CHECKED, self.on_checked) self.bone_list.Bind(wx.dataview.EVT_TREELIST_ITEM_CONTEXT_MENU, self.on_right_click) self.bone_list.Bind(wx.dataview.EVT_TREELIST_SELECTION_CHANGED, self.on_select) self.bone_list.SetDropTarget(FileDropTarget(self, "load_main_file")) # Binds self.Bind(wx.EVT_BUTTON, self.on_open, id=wx.ID_OPEN) self.Bind(wx.EVT_BUTTON, self.on_save, id=wx.ID_SAVE) self.Bind(wx.EVT_BUTTON, self.on_right_click, id=wx.ID_EDIT) self.Bind(wx.EVT_BUTTON, self.on_info, id=wx.ID_INFO) # Select All self.rename_id = wx.NewId() self.Bind(wx.EVT_MENU, self.toggle_select_all, id=wx.ID_SELECTALL) self.Bind(wx.EVT_MENU, self.on_paste, id=wx.ID_PASTE) self.Bind(wx.EVT_MENU, self.on_info, id=wx.ID_INFO) self.Bind(wx.EVT_MENU, self.on_delete, id=wx.ID_DELETE) self.Bind(wx.EVT_MENU, self.on_rename, id=self.rename_id) accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('a'), wx.ID_SELECTALL), (wx.ACCEL_CTRL, ord('i'), wx.ID_INFO), (wx.ACCEL_CTRL, ord('v'), wx.ID_PASTE), (wx.ACCEL_NORMAL, wx.WXK_DELETE, wx.ID_DELETE), (wx.ACCEL_NORMAL, wx.WXK_F2, self.rename_id), ]) self.bone_list.SetAcceleratorTable(accelerator_table) pub.subscribe(self.copy_bones, 'copy_bones') # Use some sizers to see layout options self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) self.button_sizer.Add(self.open) self.button_sizer.AddSpacer(5) self.button_sizer.Add(self.save) self.button_sizer.AddSpacer(5) self.button_sizer.Add(self.edit) self.button_sizer.AddSpacer(5) self.button_sizer.Add(self.info) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.name, 0, wx.CENTER) self.sizer.Add(self.button_sizer) self.sizer.Add(self.bone_list, 1, wx.EXPAND) # Layout sizers self.SetSizer(self.sizer) self.SetAutoLayout(1)