<commit_before>import wx
import wx.html

import prefs
from worlds import worlds
from connection import Connection

import webbrowser

class DescriptionBox(wx.html.HtmlWindow):
    def OnLinkClicked(self, link):
        webbrowser.open(link.GetHref())

conntypes = [ 'Direct', 'SSL', 'SSH Fwd' ]

class WorldsList(wx.Dialog):

    def __init__(self, parent):
        wx.Dialog.__init__(self, parent, title = 'Worlds List', style =
                wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)

        self.parent = parent

        worlds_label      = wx.StaticText(self, label = "World:")
        self.world_picker = wx.Choice(self, style     = wx.CB_SORT )

        for world in worlds: self.world_picker.Append(world)

        host_label = wx.StaticText(self, label = "Host:")
        port_label = wx.StaticText(self, label = "Port:")

        self.host = wx.TextCtrl(self)

        # stick port + type into their own boxsizer
        self.port = wx.SpinCtrl(self)
        self.port.SetRange(1, 65535)
        self.port.SetValue(7777)
        self.conntype = wx.Choice(self, choices = conntypes )
        port_sizer = wx.BoxSizer(wx.HORIZONTAL)
        port_sizer.Add(self.port,     1, wx.EXPAND)
        port_sizer.Add([5,5],         0, wx.EXPAND)
        port_sizer.Add(self.conntype, 0, wx.EXPAND)

        self.ssh_username_label = wx.StaticText(self, label = "SSH User:")
        self.ssh_loc_host_label = wx.StaticText(self, label = "SSH Host:")
        self.ssh_username       = wx.TextCtrl(self)
        self.ssh_loc_host       = wx.TextCtrl(self)

        # UI to show that ssh isn't implemented yet.
        self.ssh_unimp_box      = wx.Panel()
        self.ssh_unimplemented  = wx.StaticText(self, label = "(SSH not implemented yet)")
        self.ssh_unimplemented.SetForegroundColour("#999999")
        self.ssh_username_label.SetForegroundColour("#999999")
        self.ssh_loc_host_label.SetForegroundColour("#999999")
        self.ssh_username.Disable();
        self.ssh_loc_host.Disable();
        # end ssh-disable temp UI tweaks

        self.auto_login_check   = wx.CheckBox(self, label   = "Auto-Login")
        self.login_script_label = wx.StaticText(self, label = "Login Script:")
        self.login_script       = wx.TextCtrl(self)

        self.username_label = wx.StaticText(self, label = "Username:")
        self.password_label = wx.StaticText(self, label = "Password:")
        self.username       = wx.TextCtrl(self)
        self.password       = wx.TextCtrl(self, style   = wx.TE_PASSWORD)<commit_msg>Fix segfault on MacOS Worldlist dialog<commit_after>import wx
import wx.html

import prefs
from worlds import worlds
from connection import Connection

import webbrowser

class DescriptionBox(wx.html.HtmlWindow):
    def OnLinkClicked(self, link):
        webbrowser.open(link.GetHref())

conntypes = [ 'Direct', 'SSL', 'SSH Fwd' ]

class WorldsList(wx.Dialog):

    def __init__(self, parent):
        wx.Dialog.__init__(self, parent, title = 'Worlds List', style =
                wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)

        self.parent = parent

        worlds_label      = wx.StaticText(self, label = "World:")
        self.world_picker = wx.Choice(self, style     = wx.CB_SORT )

        for world in worlds: self.world_picker.Append(world)

        host_label = wx.StaticText(self, label = "Host:")
        port_label = wx.StaticText(self, label = "Port:")

        self.host = wx.TextCtrl(self)

        # stick port + type into their own boxsizer
        self.port = wx.SpinCtrl(self)
        self.port.SetRange(1, 65535)
        self.port.SetValue(7777)
        self.conntype = wx.Choice(self, choices = conntypes )
        port_sizer = wx.BoxSizer(wx.HORIZONTAL)
        port_sizer.Add(self.port,     1, wx.EXPAND)
        port_sizer.Add([5,5],         0, wx.EXPAND)
        port_sizer.Add(self.conntype, 0, wx.EXPAND)

        self.ssh_username_label = wx.StaticText(self, label = "SSH User:")
        self.ssh_loc_host_label = wx.StaticText(self, label = "SSH Host:")
        self.ssh_username       = wx.TextCtrl(self)
        self.ssh_loc_host       = wx.TextCtrl(self)

        # UI to show that ssh isn't implemented yet.
        self.ssh_unimp_box      = wx.StaticText(self, label = "")
        self.ssh_unimplemented  = wx.StaticText(self, label = "(SSH not implemented yet)")
        self.ssh_unimplemented.SetForegroundColour("#999999")
        self.ssh_username_label.SetForegroundColour("#999999")
        self.ssh_loc_host_label.SetForegroundColour("#999999")
        self.ssh_username.Disable();
        self.ssh_loc_host.Disable();
        # end ssh-disable temp UI tweaks

        self.auto_login_check   = wx.CheckBox(self, label   = "Auto-Login")
        self.login_script_label = wx.StaticText(self, label = "Login Script:")
        self.login_script       = wx.TextCtrl(self)

        self.username_label = wx.StaticText(self, label = "Username:")
        self.password_label = wx.StaticText(self, label = "Password:")
        self.username       = wx.TextCtrl(self)
        self.password       = wx.TextCtrl(self, style   = wx.TE_PASSWORD)
{'fraction_non_alphanumeric': 0.11433046202036022, 'fraction_numerical': 0.012920908379013312, 'mean_word_length': 2.688808664259928, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5408621', 'n_tokens_mistral': 1740, 'n_tokens_neox': 1619, 'n_words': 319}