MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / _build_floating_window

Method _build_floating_window

PySimpleGUI/PySimpleGUI.py:24061–24114  ·  view source on GitHub ↗

:param location: :type location:

(self, location=(None, None))

Source from the content-addressed store, hash-verified

24059 '''
24060
24061 def _build_floating_window(self, location=(None, None)):
24062 """
24063
24064 :param location:
24065 :type location:
24066
24067 """
24068 if self.popout_window: # if floating window already exists, close it first
24069 self.popout_window.Close()
24070 old_theme = theme()
24071 theme(_Debugger.DEBUGGER_POPOUT_THEME)
24072 num_cols = 2
24073 width_var = 15
24074 width_value = 30
24075 layout = []
24076 line = []
24077 col = 0
24078 # self.popout_choices = self.local_choices
24079 self.popout_choices = {}
24080 if self.popout_choices == {}: # if nothing chosen, then choose all non-_ variables
24081 for key in sorted(self.locals.keys()):
24082 self.popout_choices[key] = not key.startswith('_')
24083
24084 width_var = max([len(key) for key in self.popout_choices])
24085 for key in self.popout_choices:
24086 if self.popout_choices[key] is True:
24087 value = str(self.locals.get(key))
24088 h = min(len(value) // width_value + 1, _Debugger.MAX_LINES_PER_RESULT_FLOATING)
24089 line += [Text('{}'.format(key), size=(width_var, 1), font=_Debugger.DEBUGGER_POPOUT_WINDOW_FONT),
24090 Text(' = ', font=_Debugger.DEBUGGER_POPOUT_WINDOW_FONT),
24091 Text(value, key=key, size=(width_value, h), font=_Debugger.DEBUGGER_POPOUT_WINDOW_FONT)]
24092 if col + 1 < num_cols:
24093 line += [VerticalSeparator(), T(' ')]
24094 col += 1
24095 if col >= num_cols:
24096 layout.append(line)
24097 line = []
24098 col = 0
24099 if col != 0:
24100 layout.append(line)
24101 layout = [[T(SYMBOL_X, enable_events=True, key='-EXIT-', font='_ 7')], [Column(layout)]]
24102
24103 Window._read_call_from_debugger = True
24104 self.popout_window = Window('Floating', layout, alpha_channel=0, no_titlebar=True, grab_anywhere=True,
24105 element_padding=(0, 0), margins=(0, 0), keep_on_top=True,
24106 right_click_menu=['&Right', ['Debugger::RightClick', 'Exit::RightClick']], location=location, finalize=True)
24107 Window._read_call_from_debugger = False
24108
24109 if location == (None, None):
24110 screen_size = self.popout_window.GetScreenDimensions()
24111 self.popout_window.Move(screen_size[0] - self.popout_window.Size[0], 0)
24112 self.popout_window.SetAlpha(1)
24113 theme(old_theme)
24114 return True
24115
24116 ''&#x27;
24117 ######

Callers 3

readMethod · 0.80

Calls 7

themeFunction · 0.85
TextClass · 0.85
VerticalSeparatorClass · 0.85
ColumnClass · 0.85
WindowClass · 0.85
CloseMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected