def show_item_props(): sound.fx('expand') itemPropWin.show_window( selected_item.get_properties(), wid['changedefaults'], selected_sub_item.name, )
def hide_win(self, play_snd: bool=True) -> None: """Hide the window.""" if play_snd: sound.fx('config') self.withdraw() self.visible.set(False) self.save_conf() self.tool_button.state(('!pressed',))
def hide_context(e=None): """Hide the properties window, if it's open.""" global is_open, selected_item, selected_sub_item if is_open: is_open = False prop_window.withdraw() sound.fx('contract') selected_item = selected_sub_item = None
def show_win(self, play_snd: bool=True) -> None: """Show the window.""" if play_snd: sound.fx('config') self.deiconify() self.visible.set(True) self.save_conf() self.tool_button.state(('pressed',)) self.follow_main()
def sub_sel(pos, e=None): """Change the currently-selected sub-item.""" ind = ind_for_pos(pos) # Can only change the subitem on the preview window if selected_sub_item.is_pre and ind is not None: sound.fx('config') selected_sub_item.change_subtype(ind) # Redisplay the window to refresh data and move it to match show_prop(selected_sub_item, warp_cursor=True)
def _start(self, slot: 'Slot[ItemT]', event: tkinter.Event) -> None: """Start the drag.""" if slot.contents is None: return # Can't pick up blank... self._cur_drag = slot.contents show_group = False if not slot.is_source: slot.contents = None # If none of this group are present in the targets and we're # pulling from the items, we hold a group icon. try: group = self._cur_drag.dnd_group except AttributeError: pass else: if group is not None: for other_slot in self._targets: if getattr(other_slot.contents, 'dnd_group', None) == group: break else: # None present. show_group = True self._display_item(self._drag_lbl, self._cur_drag, show_group) self._cur_prev_slot = slot sound.fx('config') self._drag_win.deiconify() self._drag_win.lift(slot._lbl.winfo_toplevel()) # grab makes this window the only one to receive mouse events, so # it is guaranteed that it'll drop when the mouse is released. self._drag_win.grab_set_global() # NOTE: _global means no other programs can interact, make sure # it's released eventually or you won't be able to quit! # Call this to reposition it. self._evt_move(event) self._drag_win.bind(utils.EVENTS['LEFT_MOVE'], self._evt_move)
def _evt_stop(self, event: tkinter.Event) -> None: """User released the item.""" if self._cur_drag is None or self._cur_prev_slot is None: return sound.fx('config') self._drag_win.grab_release() self._drag_win.withdraw() self._drag_win.unbind(tk_tools.EVENTS['LEFT_MOVE']) dest = self._pos_slot(event.x_root, event.y_root) if dest: # We have a target. dest.contents = self._cur_drag # No target, and we dragged off an existing target - delete. elif not self._cur_prev_slot.is_source: sound.fx('delete') self._cur_drag = None self._cur_prev_slot = None
def _evt_fastdrag(self, event: tkinter.Event) -> None: """Quickly add/remove items by shift-clicking.""" if self.is_source: # Add this item to the first free position. item = self.contents for slot in self.man._targets: if slot.contents is None: slot.contents = item sound.fx('config') return elif slot.contents is item: # It's already on the board, don't change anything. sound.fx('config') return sound.fx('delete') else: # Fast-delete this. self.contents = None sound.fx('delete')
def func(e): sound.fx('expand') show_prop(item)
def sub_open(pos, e=None): """Move the context window to apply to the given item.""" ind = ind_for_pos(pos) if ind is not None: sound.fx('expand') selected_sub_item.open_menu_at_sub(ind)
def hide_item_props(vals): sound.fx('contract') selected_item.set_properties(vals)