def on_change_file(self, event: wx.Event): # フォーム無効化 self.disable() # 出力先をCSVパネルのコンソールに変更 sys.stdout = self.console_ctrl # ファイルコントロール自身のパス確定処理 # 先頭と末尾の改行は除去 target_path = self.pmx_file_ctrl.file_ctrl.GetPath().strip() logger.test("target_path strip: %s", target_path) # 先頭と末尾のダブルクォーテーションは除去 target_path = re.sub(r'^\\+\"(\w)\\', r'\1:\\', target_path) target_path = target_path.strip("\"") logger.test("target_path strip: %s", target_path) # 再設定 self.pmx_file_ctrl.file_ctrl.SetPath(target_path) # ファイル読み込み処理 if self.pmx_file_ctrl.is_valid() and self.pmx_file_ctrl.load(is_check=False): # モーフ展開処理 morph_names = {"目": [], "眉": [], "口": [], "他": []} for mk, mv in self.pmx_file_ctrl.data.morphs.items(): if mv.display: morph_names[mv.get_panel_name()].append(mk) self.morph_eye_list.SetItems(morph_names["目"]) self.morph_eyebrow_list.SetItems(morph_names["眉"]) self.morph_lip_list.SetItems(morph_names["口"]) self.morph_other_list.SetItems(morph_names["他"]) # フォーム有効化 self.enable() event.Skip()
def on_save( self, event: wx.Event ) -> None: # wxGlade: BitmapSaverFrame.<event_handler> """ Save the icon with the current settings. :param event: """ self.update_preview(self, event) # from https://wxpython.org/Phoenix/docs/html/wx.FileDialog.html filedlg = wx.FileDialog( self, f"Save {self.filetype.filetype_string} file", wildcard=self.filetype.wildcard, style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT, ) if filedlg.ShowModal() == wx.ID_CANCEL: return # the user changed their mind # save the current contents in the file self.filename = filedlg.GetPath() if os.path.splitext(self.filename)[-1] != self.filetype.extension: self.filename = self.filename + self.filetype.extension wx.ArtProvider.GetBitmap( self.icon, self.provider, wx.Size(self.size, self.size), ).SaveFile(self.filename, self.filetype.ftype) filedlg.Destroy() event.Skip()
def on_doubleclick(self, event: wx.Event): self.timer.Stop() logger.warning("ダブルクリックされました。", decoration=MLogger.DECORATION_BOX) event.Skip(False) return False
def on_command_focused(self, event: wx.Event): """Event handler for the command_ui_list's EVT_LIST_ITEM_FOCUSED.""" ui = self.uimgr.command_ui_list[event.GetIndex()] self.uimgr.activate(self.settings_panel, ui)
def use_location_handler(self, event: wx.Event): event.Skip() self.save.Enable(not self.use_location.IsChecked()) self.save_select.Enable(not self.use_location.IsChecked())
def select_path_location(self, event: wx.Event): event.Skip() self.select_folder(self.path, 'Select a source folder')
def on_toggle(self, event: wx.Event): obj = event.GetEventObject() val = obj.GetValue() obj.SetLabel('Continuous' if val else 'One-shot') self.mf.device.set_trigger_mode(self.ch, val) self.continuous = val
def _on_select(self, event: wx.Event): item = self.GetItem(event.GetIndex(), 1).GetText() nomenclature = self.GetItem(event.GetIndex(), 9).GetText() logger.debug(f'Selected={item=},' f' {nomenclature=}') wx.PostEvent(self.main_frame, Selected(id=item, nomenclature=nomenclature))
def initialize(self, event: wx.Event): if 1 in self.avoidance_set_dict: # ファイルタブ用接触回避のファイルセットがある場合 if self.frame.file_panel_ctrl.file_set.is_loaded(): # 既にある場合、ハッシュチェック if self.avoidance_set_dict[1].equal_hashdigest( self.frame.file_panel_ctrl.file_set): # 同じである場合、スルー pass else: # 違う場合、ファイルセット読み直し self.add_set(1, self.frame.file_panel_ctrl.file_set, replace=True) else: # ファイルタブが読み込み失敗している場合、読み直し(クリア) self.add_set(1, self.frame.file_panel_ctrl.file_set, replace=True) else: # 空から作る場合、ファイルタブのファイルセット参照 self.add_set(1, self.frame.file_panel_ctrl.file_set, replace=False) # multiはあるだけ調べる for multi_file_set_idx, multi_file_set in enumerate( self.frame.multi_panel_ctrl.file_set_list): set_no = multi_file_set_idx + 2 if set_no in self.avoidance_set_dict: # 複数タブ用接触回避のファイルセットがある場合 if multi_file_set.is_loaded(): # 既にある場合、ハッシュチェック if self.avoidance_set_dict[set_no].equal_hashdigest( multi_file_set): # 同じである場合、スルー pass else: # 違う場合、ファイルセット読み直し self.add_set(set_no, multi_file_set, replace=True) # 複数件ある場合、手首間の距離デフォルト値変更 self.alignment_distance_wrist_slider.SetValue(2.5) self.alignment_distance_wrist_label.SetLabel("(2.5)") else: # 複数タブが読み込み失敗している場合、読み直し(クリア) self.add_set(set_no, multi_file_set, replace=True) # 複数件ある場合、手首間の距離デフォルト値変更 self.alignment_distance_wrist_slider.SetValue(2.5) self.alignment_distance_wrist_label.SetLabel("(2.5)") else: # 空から作る場合、複数タブのファイルセット参照 self.add_set(set_no, multi_file_set, replace=False) # 複数件ある場合、手首間の距離デフォルト値変更 self.alignment_distance_wrist_slider.SetValue(2.5) self.alignment_distance_wrist_label.SetLabel("(2.5)") # 腕系不可モデル名リスト disable_arm_model_names = [] if self.frame.file_panel_ctrl.file_set.is_loaded(): if not self.frame.file_panel_ctrl.file_set.org_model_file_ctrl.data.can_arm_sizing: # 腕不可の場合、リスト追加 disable_arm_model_names.append("【No.1】作成元モデル: {0}".format( self.frame.file_panel_ctrl.file_set.org_model_file_ctrl. data.name)) if not self.frame.file_panel_ctrl.file_set.rep_model_file_ctrl.data.can_arm_sizing: # 腕不可の場合、リスト追加 disable_arm_model_names.append("【No.1】変換先モデル: {0}".format( self.frame.file_panel_ctrl.file_set.rep_model_file_ctrl. data.name)) for multi_file_set_idx, multi_file_set in enumerate( self.frame.multi_panel_ctrl.file_set_list): set_no = multi_file_set_idx + 2 if multi_file_set.is_loaded(): if not multi_file_set.org_model_file_ctrl.data.can_arm_sizing: # 腕不可の場合、リスト追加 disable_arm_model_names.append( "【No.{0}】作成元モデル: {1}".format( set_no, multi_file_set.org_model_file_ctrl.data.name)) if not multi_file_set.rep_model_file_ctrl.data.can_arm_sizing: # 腕不可の場合、リスト追加 disable_arm_model_names.append( "【No.{0}】変換先モデル: {1}".format( set_no, multi_file_set.rep_model_file_ctrl.data.name)) if len(disable_arm_model_names) > 0: # 腕不可モデルがいる場合、ダイアログ表示 with wx.MessageDialog(self, "下記モデルに「腕IK」に類する文字列が含まれているため、該当ファイルセットの腕系処理\n(腕スタンス補正・捩り分散・接触回避・位置合わせ)がこのままではスルーされます。\n" \ + "腕チェックスキップFLGをONにすると、強制的に腕系処理が実行されます。\n※ただし、結果がおかしくなってもサポート対象外となります。\n" \ + "腕チェックスキップFLGをONにしますか? \n\n{0}".format('\n'.join(disable_arm_model_names)), style=wx.YES_NO | wx.ICON_WARNING) as dialog: if dialog.ShowModal() == wx.ID_NO: # 腕系チェックスキップOFF self.arm_check_skip_flg_ctrl.SetValue(0) else: # 腕系チェックスキップON self.arm_check_skip_flg_ctrl.SetValue(1) event.Skip()
def on_paint(self, event: wx.Event): self.SetCurrent(self.context) if not self.is_gl_initialized: self.init_gl() self.on_draw() event.Skip()
def choose(self, event: wx.Event): self.set_values() event.Skip()
def __on_col_begin_drag(self, event: wx.Event): event.Veto()
def state_change(self, e: wx.Event): e_obj: wx.CheckBox = e.GetEventObject() command = f"{e_obj.GetLabel().lower()} {'on' if e_obj.GetValue() else 'off'}" print(command) resp = self.send_command(command)
def on_tab_change(self, event: wx.Event): if self.file_panel_ctrl.is_fix_tab: self.note_ctrl.ChangeSelection(self.file_panel_ctrl.tab_idx) event.Skip() return elif self.morph_panel_ctrl.is_fix_tab: # モーフタブの固定が指定されている場合、固定はファイルタブ self.note_ctrl.ChangeSelection(self.file_panel_ctrl.tab_idx) event.Skip() return elif self.arm_panel_ctrl.is_fix_tab: # 腕タブの固定が指定されている場合、固定はファイルタブ self.note_ctrl.ChangeSelection(self.file_panel_ctrl.tab_idx) event.Skip() return elif self.csv_panel_ctrl.is_fix_tab: self.note_ctrl.ChangeSelection(self.csv_panel_ctrl.tab_idx) event.Skip() return elif self.vmd_panel_ctrl.is_fix_tab: self.note_ctrl.ChangeSelection(self.vmd_panel_ctrl.tab_idx) event.Skip() return elif self.bulk_panel_ctrl.is_fix_tab: self.note_ctrl.ChangeSelection(self.bulk_panel_ctrl.tab_idx) event.Skip() return if self.note_ctrl.GetSelection() == self.multi_panel_ctrl.tab_idx: # 複数タブ移動時に保存 self.file_panel_ctrl.save() if self.note_ctrl.GetSelection() == self.morph_panel_ctrl.tab_idx: # コンソールクリア self.file_panel_ctrl.console_ctrl.Clear() wx.GetApp().Yield() # 一旦ファイルタブに固定 self.note_ctrl.SetSelection(self.file_panel_ctrl.tab_idx) self.morph_panel_ctrl.fix_tab() logger.info("モーフタブ表示準備開始\nファイル読み込み処理を実行します。少しお待ちください....", decoration=MLogger.DECORATION_BOX) # 読み込み処理実行 self.load(event, target_idx=0, is_morph=True) if self.note_ctrl.GetSelection() == self.arm_panel_ctrl.tab_idx: # コンソールクリア self.file_panel_ctrl.console_ctrl.Clear() wx.GetApp().Yield() # 一旦ファイルタブに固定 self.note_ctrl.SetSelection(self.file_panel_ctrl.tab_idx) self.arm_panel_ctrl.fix_tab() logger.info("腕タブ表示準備開始\nファイル読み込み処理を実行します。少しお待ちください....", decoration=MLogger.DECORATION_BOX) # 読み込み処理実行 self.load(event, target_idx=0, is_arm=True) if self.note_ctrl.GetSelection() == self.camera_panel_ctrl.tab_idx: # カメラタブを開く場合、カメラタブ初期化処理実行 self.note_ctrl.ChangeSelection(self.camera_panel_ctrl.tab_idx) self.camera_panel_ctrl.initialize(event)
def close_window(self, evt: wx.Event): evt.StopPropagation() print('Exiting without complete configuration.') self.Destroy() self.on_cancel()
def on_load_result(self, event: wx.Event): self.elapsed_time = event.elapsed_time # タブ移動可 self.release_tab() # フォーム有効化 self.enable() # ワーカー終了 self.load_worker = None # プログレス非表示 self.file_panel_ctrl.gauge_ctrl.SetValue(0) # チェックボタンに切り替え self.file_panel_ctrl.check_btn_ctrl.SetLabel("変換前チェック") self.file_panel_ctrl.check_btn_ctrl.Enable() if not event.result: # 終了音を鳴らす self.sound_finish() event.Skip() return False result = self.is_loaded_valid() if not result: # 終了音を鳴らす self.sound_finish() # タブ移動可 self.release_tab() # フォーム有効化 self.enable() event.Skip() return False logger.info("ファイルデータ読み込みが完了しました", decoration=MLogger.DECORATION_BOX, title="OK") if event.is_exec: # そのまま実行する場合、サイジング実行処理に遷移 # 念のため出力ファイルパス自動生成(空の場合設定) if not self.file_panel_ctrl.file_set.output_vmd_file_ctrl.file_ctrl.GetPath( ): self.file_panel_ctrl.file_set.set_output_vmd_path(event) # multiのも出力ファイルパス自動生成(空の場合設定) for file_set in self.multi_panel_ctrl.file_set_list: if not file_set.output_vmd_file_ctrl.file_ctrl.GetPath(): file_set.set_output_vmd_path(event) # フォーム無効化 self.file_panel_ctrl.disable() # タブ固定 self.file_panel_ctrl.fix_tab() if self.worker: logger.error("まだ処理が実行中です。終了してから再度実行してください。", decoration=MLogger.DECORATION_BOX) else: # 停止ボタンに切り替え self.file_panel_ctrl.exec_btn_ctrl.SetLabel("VMDサイジング停止") self.file_panel_ctrl.exec_btn_ctrl.Enable() # 別スレッドで実行 self.worker = SizingWorkerThread(self, SizingThreadEvent, event.target_idx, self.is_saving, self.is_out_log) self.worker.start() elif event.is_morph: # モーフタブを開く場合、モーフタブ初期化処理実行 self.note_ctrl.ChangeSelection(self.morph_panel_ctrl.tab_idx) self.morph_panel_ctrl.initialize(event) elif event.is_arm: # 腕タブを開く場合、腕タブ初期化処理実行 self.note_ctrl.ChangeSelection(self.arm_panel_ctrl.tab_idx) self.arm_panel_ctrl.initialize(event) else: # 終了音を鳴らす self.sound_finish() logger.info("\n処理時間: %s", self.show_worked_time()) event.Skip() return True
def on_text_enter(self, event: wx.Event): event_obj = event.GetEventObject() if event_obj == self.search_bar: med_id = self.in_grid.current_id self.out_grid.add(med_id)
def on_dir_change(event: wx.Event, callback: Callable): callback(event.GetString())
def on_close(self, event: wx.Event): self.client_thread.should_terminate = True self.client_thread.join() self.capture_timer.Stop() self.animation_timer.Stop() event.Skip()
def on_num_of_pulses(self, event: wx.Event): self.num_of_pulses.SetValue(self.num_of_pulses.GetValue()) self.modify_callback(self.label) event.Skip()
def item_clicked(self, event: wx.Event) -> None: item = event.GetItem() listnode = self.tree_ctrl.GetItemData(item) if self.item_clicked_cb is not None: self.item_clicked_cb(event, listnode)
def select_save_location(self, event: wx.Event): event.Skip() self.select_folder(self.save, 'Select a destination folder')
def on_enter_choice(self, event: wx.Event, midx: int): idx = event.GetEventObject().FindString( event.GetEventObject().GetValue()) if idx >= 0: event.GetEventObject().SetSelection(idx) self.on_change_choice(event, midx)
def on_file_history(self, event: wx.Event): fileNum = event.GetId() - wx.ID_FILE1 path = self.filehistory.GetHistoryFile(fileNum) self.open_file(path, True)
def on_change_choice(self, event: wx.Event, midx: int): text = event.GetEventObject().GetStringSelection() # 同じ選択肢を初期設定 if len(self.org_choices[midx].GetValue()) == 0 or len(text) == 0: self.org_choices[midx].ChangeValue(text) cidx = self.org_choices[midx].FindString(text) if cidx >= 0: self.org_choices[midx].SetSelection(cidx) if text in self.panel.model_file_ctrl.data.bones: bone_data = self.panel.model_file_ctrl.data.bones[text] if bone_data.getTranslatable(): # 移動ボーン if len(self.rep_mx_choices[midx].GetValue()) == 0: mxtext = f'{text}MX' cidx = self.rep_mx_choices[midx].FindString(mxtext) if cidx >= 0: self.rep_mx_choices[midx].ChangeValue(mxtext) self.rep_mx_choices[midx].SetSelection(cidx) else: self.rep_mx_choices[midx].ChangeValue(text) cidx = self.rep_mx_choices[midx].FindString(text) if cidx >= 0: self.rep_mx_choices[midx].SetSelection(cidx) if len(self.rep_my_choices[midx].GetValue()) == 0: mytext = f'{text}MY' cidx = self.rep_my_choices[midx].FindString(mytext) if cidx >= 0: self.rep_my_choices[midx].ChangeValue(mytext) self.rep_my_choices[midx].SetSelection(cidx) else: self.rep_my_choices[midx].ChangeValue(text) cidx = self.rep_my_choices[midx].FindString(text) if cidx >= 0: self.rep_my_choices[midx].SetSelection(cidx) if len(self.rep_mz_choices[midx].GetValue()) == 0: mztext = f'{text}MZ' cidx = self.rep_mz_choices[midx].FindString(mztext) if cidx >= 0: self.rep_mz_choices[midx].ChangeValue(mztext) self.rep_mz_choices[midx].SetSelection(cidx) else: self.rep_mz_choices[midx].ChangeValue(text) cidx = self.rep_mz_choices[midx].FindString(text) if cidx >= 0: self.rep_mz_choices[midx].SetSelection(cidx) if bone_data.getRotatable(): # 回転ボーン if len(self.rep_rx_choices[midx].GetValue()) == 0: rxtext = f'{text}RX' cidx = self.rep_rx_choices[midx].FindString(rxtext) if cidx >= 0: self.rep_rx_choices[midx].ChangeValue(rxtext) self.rep_rx_choices[midx].SetSelection(cidx) else: self.rep_rx_choices[midx].ChangeValue(text) cidx = self.rep_rx_choices[midx].FindString(text) if cidx >= 0: self.rep_rx_choices[midx].SetSelection(cidx) if len(self.rep_ry_choices[midx].GetValue()) == 0: rytext = f'{text}RY' cidx = self.rep_ry_choices[midx].FindString(rytext) if cidx >= 0: self.rep_ry_choices[midx].ChangeValue(rytext) self.rep_ry_choices[midx].SetSelection(cidx) else: self.rep_ry_choices[midx].ChangeValue(text) cidx = self.rep_ry_choices[midx].FindString(text) if cidx >= 0: self.rep_ry_choices[midx].SetSelection(cidx) if len(self.rep_rz_choices[midx].GetValue()) == 0: rztext = f'{text}RZ' cidx = self.rep_rz_choices[midx].FindString(rztext) if cidx >= 0: self.rep_rz_choices[midx].ChangeValue(rztext) self.rep_rz_choices[midx].SetSelection(cidx) else: self.rep_rz_choices[midx].ChangeValue(text) cidx = self.rep_rz_choices[midx].FindString(text) if cidx >= 0: self.rep_rz_choices[midx].SetSelection(cidx) elif len(text) == 0: # 空にした場合は空に self.org_choices[midx].ChangeValue("") self.org_choices[midx].SetSelection(-1) self.rep_mx_choices[midx].ChangeValue("") self.rep_mx_choices[midx].SetSelection(-1) self.rep_my_choices[midx].ChangeValue("") self.rep_my_choices[midx].SetSelection(-1) self.rep_mz_choices[midx].ChangeValue("") self.rep_mz_choices[midx].SetSelection(-1) self.rep_rx_choices[midx].ChangeValue("") self.rep_rx_choices[midx].SetSelection(-1) self.rep_ry_choices[midx].ChangeValue("") self.rep_ry_choices[midx].SetSelection(-1) self.rep_rz_choices[midx].ChangeValue("") self.rep_rz_choices[midx].SetSelection(-1) # 最後である場合、行追加 if midx == len(self.org_choices) - 1 and self.org_choices[midx].GetSelection() > 0 and \ (len(self.rep_mx_choices[midx].GetStringSelection()) > 0 or len(self.rep_my_choices[midx].GetStringSelection()) > 0 \ or len(self.rep_mz_choices[midx].GetStringSelection()) > 0 or len(self.rep_rx_choices[midx].GetStringSelection()) > 0 \ or len(self.rep_ry_choices[midx].GetStringSelection()) > 0 or len(self.rep_rz_choices[midx].GetStringSelection()) > 0): self.add_line(midx + 1)
def on_command_end_labeledit(self, event: wx.Event): index = event.GetIndex() name = event.GetText() self.uimgr.set_item_name(index, name)
def on_size(self, event: wx.Event): # width = event.GetSize()[0] # for col, _v in enumerate(self.labels): # self.SetColSize(col, width/len(self.labels)) event.Skip()
def on_convert(self, event: wx.Event): self.timer.Stop() self.Unbind(wx.EVT_TIMER, id=TIMER_ID) # フォーム無効化 self.disable() # タブ固定 self.fix_tab() # コンソールクリア self.console_ctrl.Clear() # 出力先を多段統合パネルのコンソールに変更 sys.stdout = self.console_ctrl self.vmd_file_ctrl.save() self.model_file_ctrl.save() # JSON出力 MFileUtils.save_history(self.frame.mydir_path, self.frame.file_hitories) self.elapsed_time = 0 result = True result = self.vmd_file_ctrl.is_valid() and result result = self.model_file_ctrl.is_valid() and result if len(self.bone_target_txt_ctrl.GetValue()) == 0: logger.error("統合対象ボーンが指定されていません。", decoration=MLogger.DECORATION_BOX) result = False if not result: # 終了音 self.frame.sound_finish() # タブ移動可 self.release_tab() # フォーム有効化 self.enable() return result # 多段統合変換開始 if self.multi_join_btn_ctrl.GetLabel( ) == "多段統合停止" and self.convert_multi_join_worker: # フォーム無効化 self.disable() # 停止状態でボタン押下時、停止 self.convert_multi_join_worker.stop() # タブ移動可 self.frame.release_tab() # フォーム有効化 self.frame.enable() # ワーカー終了 self.convert_multi_join_worker = None # プログレス非表示 self.gauge_ctrl.SetValue(0) logger.warning("多段統合を中断します。", decoration=MLogger.DECORATION_BOX) self.multi_join_btn_ctrl.SetLabel("多段統合") event.Skip(False) elif not self.convert_multi_join_worker: # フォーム無効化 self.disable() # タブ固定 self.fix_tab() # コンソールクリア self.console_ctrl.Clear() # ラベル変更 self.multi_join_btn_ctrl.SetLabel("多段統合停止") self.multi_join_btn_ctrl.Enable() self.convert_multi_join_worker = MultiJoinWorkerThread( self.frame, MultiJoinThreadEvent, self.frame.is_saving, self.frame.is_out_log) self.convert_multi_join_worker.start() event.Skip() else: logger.error("まだ処理が実行中です。終了してから再度実行してください。", decoration=MLogger.DECORATION_BOX) event.Skip(False) return result
def on_convert(self, event: wx.Event): self.timer.Stop() self.Unbind(wx.EVT_TIMER, id=TIMER_ID) # フォーム無効化 self.disable() # タブ固定 self.fix_tab() # コンソールクリア self.console_ctrl.Clear() # 出力先をスムージングパネルのコンソールに変更 sys.stdout = self.console_ctrl wx.GetApp().Yield() self.smooth_vmd_file_ctrl.save() self.smooth_model_file_ctrl.save() # JSON出力 MFileUtils.save_history(self.frame.mydir_path, self.frame.file_hitories) self.elapsed_time = 0 result = True result = self.smooth_vmd_file_ctrl.is_valid( ) and self.smooth_model_file_ctrl.is_valid() and result # スムージング変換開始 if self.smooth_btn_ctrl.GetLabel( ) == "スムージング停止" and self.convert_smooth_worker: # フォーム無効化 self.disable() # 停止状態でボタン押下時、停止 self.convert_smooth_worker.stop() # タブ移動可 self.frame.release_tab() # フォーム有効化 self.frame.enable() # ワーカー終了 self.convert_smooth_worker = None # プログレス非表示 self.gauge_ctrl.SetValue(0) logger.warning("スムージングを中断します。", decoration=MLogger.DECORATION_BOX) self.smooth_btn_ctrl.SetLabel("スムージング実行") event.Skip(False) elif not self.convert_smooth_worker: # フォーム無効化 self.disable() # タブ固定 self.fix_tab() # コンソールクリア self.console_ctrl.Clear() # ラベル変更 self.smooth_btn_ctrl.SetLabel("スムージング停止") self.smooth_btn_ctrl.Enable() self.convert_smooth_worker = SmoothWorkerThread( self.frame, SmoothThreadEvent, self.frame.is_saving, self.frame.is_out_log) self.convert_smooth_worker.start() event.Skip() else: logger.error("まだ処理が実行中です。終了してから再度実行してください。", decoration=MLogger.DECORATION_BOX) event.Skip(False) return result