Und jetzt? Ich habs jetzt nochmal so gemacht das sich der Text anpasst, und wenn das OS nicht Windows ist dann werden die Buttons bloß einen Buchstaben breit.
Ach ja, und wie siehts mit der Anordnung in der ersten Zeile aus, und werden jetzt endlich alle Farb-Buttons angezeigt?
Code: Alles auswählen
self.BACKGROUND_COLOR = '#000000'
self.TEXT_COLOR = '#00ff00'
self.client = None
self.client_commands = {'-cls': [self.clear_output, 'Löscht den ihnhalt der Konsole'],
'-clear': [self.clear_output, 'Löscht den ihnhalt der Konsole'],
'-disconnect': [self.disconnect, 'Trennt die Verbindung zum aktuell verbundenen server'],
'-colors': [self.help_colors_and_styles, '§cHilfe §dzur §6Schriftformatierung'],
'-help': [self.help_commands, 'Zeigt diese befehlsübersicht an'],}
self.colors_and_styles = {'0': ['Schwarz', '#000000', '#ffffff'],
'1': ['Dunkel Blau', '#0000aa', self.BACKGROUND_COLOR],
'2': ['Dunkel Grün', '#00aa00', self.BACKGROUND_COLOR],
'3': ['Dunkel Türkis', '#00aaaa', self.BACKGROUND_COLOR],
'4': ['Dunkel Rot', '#aa0000', self.BACKGROUND_COLOR],
'5': ['Lila', '#aa00aa', self.BACKGROUND_COLOR],
'6': ['Gold', '#ffaa00', self.BACKGROUND_COLOR],
'7': ['Grau', '#aaaaaa', self.BACKGROUND_COLOR],
'8': ['Dunkel Grau', '#555555', self.BACKGROUND_COLOR],
'9': ['Blau', '#5555ff', self.BACKGROUND_COLOR],
'a': ['hell Grün', '#55ff55', self.BACKGROUND_COLOR],
'b': ['Türkis', '#55ffff', self.BACKGROUND_COLOR],
'c': ['Rot', '#ff5555', self.BACKGROUND_COLOR],
'd': ['Rosa', '#ff55ff', self.BACKGROUND_COLOR],
'e': ['Gelb', '#ffff55', self.BACKGROUND_COLOR],
'f': ['Weiß', '#ffffff', self.BACKGROUND_COLOR],
'k': ['Zufällige Zeichen', None, '?'],
'l': ['Fett schreiben', None, 'F'],
'm': ['Durchgestrichen', None, '-'],
'n': ['Unterstrichen', None, 'U'],
'o': ['schräg schreiben', None, 'K'],
## 'a': ['a', None, 'a'],
## 'b': ['b', None, 'b'],
## 'c': ['c', None, 'c'],
## 'd': ['d', None, 'd'],
## 'e': ['e', None, 'e'],
## 'f': ['f', None, ''],
## 'g': ['g', None, 'g'],
## 'h': ['h', None, 'h'],
## 'i': ['i', None, 'i'],
## 'j': ['j', None, 'j'],
'r': ['Zurücksetzten', '#ffffff', self.BACKGROUND_COLOR]}
self.window = tkinter.Toplevel(bg=self.BACKGROUND_COLOR)
self.window.title('Minecraft remote console client ' + version)
self.window.protocol("WM_DELETE_WINDOW", exit_func)
self.window.wm_iconbitmap(os.path.join(icon_path, 'icon.ico'))
self.window.resizable(0, 0)
self.entrys_frame = tkinter.Frame(self.window, bg=self.BACKGROUND_COLOR)
self.entrys_frame.pack(fill='x')
tkinter.Label(self.entrys_frame, text='Host:', bg=self.BACKGROUND_COLOR, fg=self.TEXT_COLOR).pack(side='left')
self.host_entry = tkinter.Entry(self.entrys_frame, width=30, bg=self.BACKGROUND_COLOR, fg=self.TEXT_COLOR, insertbackground=self.TEXT_COLOR)
self.host_entry.pack(side='left', padx=15)
tkinter.Label(self.entrys_frame, text='Port:', bg=self.BACKGROUND_COLOR, fg=self.TEXT_COLOR).pack(side='left')
self.port_entry = tkinter.Entry(self.entrys_frame, width=6, bg=self.BACKGROUND_COLOR, fg=self.TEXT_COLOR, insertbackground=self.TEXT_COLOR)
self.port_entry.pack(side='left', padx=15)
self.port_entry.insert('end', '25575')
tkinter.Label(self.entrys_frame, text='Passwort:', bg=self.BACKGROUND_COLOR, fg=self.TEXT_COLOR).pack(side='left')
self.password_entry = tkinter.Entry(self.entrys_frame, width=20, show='*', bg=self.BACKGROUND_COLOR, fg=self.TEXT_COLOR, insertbackground=self.TEXT_COLOR)
self.password_entry.pack(side='left', padx=15)
self.connect_button = tkinter.Button(self.entrys_frame, text='Verbinden', bg=self.BACKGROUND_COLOR, fg=self.TEXT_COLOR, activeforeground='#000000',
activebackground=self.TEXT_COLOR, command=self.connect)
self.connect_button.pack(side='right', ipadx=10)
self.connect_button.bind("<Return>", self.connect)
self.textframe = tkinter.Frame(self.window)
self.textframe.pack(fill='x')
self.scrollbar = tkinter.Scrollbar(self.textframe, bg=self.BACKGROUND_COLOR, troughcolor=self.TEXT_COLOR)
self.scrollbar.pack(side='right', fill='y')
self.output_text = tkinter.Text(self.textframe, height=15, state='disable', bg=self.BACKGROUND_COLOR, yscrollcommand=self.scrollbar.set)
self.output_text.pack(side='left', expand=True, fill='x')
self.scrollbar.config(command=self.output_text.yview)
for tag_name in self.colors_and_styles:
if not self.colors_and_styles[tag_name][1] is None:
self.output_text.tag_config(tag_name, foreground=self.colors_and_styles[tag_name][1], background=self.colors_and_styles[tag_name][2])
self.output('§4[info]§r: -help eigeben um befehlsübersicht anzuzeigen')
## self.output('§0T§1T§2T§3T§4T§5T§6T§7T§8T§9T§aT§bT§cT§dT§eT§fT')
## self.output('§4R§6e§eg§ae§bn§3b§1o§5g§4e§cn')
self.colors_frame = tkinter.Frame(self.window, bg=self.BACKGROUND_COLOR)
self.colors_frame.pack(fill='x')
tkinter.Label(self.colors_frame, text='Farben:', bg=self.BACKGROUND_COLOR, fg=self.TEXT_COLOR).pack(side='left')
self.command_entry = tkinter.Entry(self.window, bg=self.BACKGROUND_COLOR, fg=self.TEXT_COLOR, insertbackground=self.TEXT_COLOR)
self.font_style_Frame = tkinter.Frame(self.colors_frame)
self.font_style_Frame.pack(side='left', padx=15)
button_width = 2
if sys.platform != 'win32':
button_width = 0
column_count = 0
for tag_name in self.colors_and_styles:
if tag_name == 'r':
tkinter.Button(self.font_style_Frame, text='N', width=button_width, relief='groove',
bg=self.BACKGROUND_COLOR, fg=self.TEXT_COLOR,
activeforeground=self.BACKGROUND_COLOR,
activebackground=self.TEXT_COLOR,
command=functools.partial(self.command_entry.insert, 'insert', '§'+tag_name)).grid(row=0, column=column_count)
elif not self.colors_and_styles[tag_name][1] is None:
tkinter.Button(self.font_style_Frame, text=tag_name, width=button_width,
foreground=self.colors_and_styles[tag_name][1],
background=self.colors_and_styles[tag_name][1],
activeforeground=self.colors_and_styles[tag_name][1],
activebackground=self.colors_and_styles[tag_name][1], relief='groove',
command=functools.partial(self.command_entry.insert, 'insert', '§'+tag_name)).grid(row=0, column=column_count)
else:
tkinter.Button(self.font_style_Frame, text=self.colors_and_styles[tag_name][2], width=button_width, relief='groove',
bg=self.BACKGROUND_COLOR,
fg=self.TEXT_COLOR,
activeforeground=self.BACKGROUND_COLOR,
activebackground=self.TEXT_COLOR,
command=functools.partial(self.command_entry.insert, 'insert', '§'+tag_name)).grid(row=0, column=column_count)
column_count += 1
tkinter.Button(self.colors_frame, text='Verbindung trennen', bg=self.BACKGROUND_COLOR, fg=self.TEXT_COLOR, activeforeground=self.BACKGROUND_COLOR,
activebackground=self.TEXT_COLOR, command=self.disconnect).pack(side='right')
self.command_entry.pack(fill='x')
self.command_entry.bind("<Return>", self.sendcommand)