def __init__(self, parent, notebook, windowtype): wx.Panel.__init__(self, notebook) self.parent = parent self.windowtype = windowtype box = wx.BoxSizer() grid = wx.FlexGridSizer(0, 1, 5, 5) if self.windowtype == self.parent.paths["online"]: self.widget = self.parent.userlist = WebView.New(self) self.widget.LoadURL(self.windowtype) elif self.windowtype == "contacts": self.widget = UltimateListCtrl(self, agwStyle=ULC_LIST | ULC_SHOW_TOOLTIPS) grid.Add(self.widget, 1, wx.EXPAND) box.Add(grid, 1, wx.EXPAND) grid.AddGrowableCol(0) grid.AddGrowableRow(0) if self.windowtype == "contacts": self.contact_name = wx.TextCtrl(self, style=wx.TE_PROCESS_ENTER) add_contact = wx.Button(self, label="Add contact") grid.AddMany([(self.contact_name, 1, wx.EXPAND), (add_contact, 1, wx.EXPAND)]) self.Bind(wx.EVT_BUTTON, self.add_contact, add_contact) self.contact_name.Bind(wx.EVT_KEY_DOWN, self.add_contact_hotkey) self.SetSizer(box)
def _InitUI(self): """Builds this UI component. Obviously, must be called in the UI thread. """ # -- Header # -- self.headerCtrl = wx.TextCtrl(self, wx.ID_ANY, style=wx.BORDER_NONE | wx.TE_DONTWRAP | wx.TE_READONLY) self.headerCtrl.SetBackgroundColour(self.GetBackgroundColour()) # -- View # -- if WEB_VIEW: self.webView = WebView.New(self) self.webView.SetBackgroundColour(self.GetBackgroundColour()) else: self.webView = HtmlWindow(self) # -- Lay Out # -- sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self.headerCtrl, 0, wx.ALIGN_CENTRE_VERTICAL | wx.ALIGN_LEFT | wx.ALL | wx.EXPAND, 2) sizer.Add(self.webView, 1, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_TOP | wx.EXPAND, 4) self.SetAutoLayout(True) self.SetSizer(sizer) # -- Events # -- self.Bind(wx.EVT_CONTEXT_MENU, self._OnContextMenu)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.browser = WebView.New(self) bsizer = wx.BoxSizer() bsizer.Add(self.browser, 1, wx.EXPAND) self.SetSizerAndFit(bsizer) htmlText = "<p>Please open a file to convert from File Menu.</p>" self.browser.SetPage(htmlText, "")
def wxview(html, url="", size=(850, 540)): import wx from wx.html2 import WebView frame = wx.Frame(None, -1, size=size) view = WebView.New(frame) view.SetPage(html, url) frame.Show() return frame
def view_url_wxapp(url): import wx # type: ignore from wx.html2 import WebView app = wx.App() frame = wx.Frame(None, -1, size=(850, 540)) view = WebView.New(frame) view.LoadURL(url) frame.Show() app.MainLoop()
def wxview(html, url="", size=(850, 540)): # type: (str, str, Tuple[int, int]) -> "wx.Frame" """View HTML in a wx dialog""" import wx from wx.html2 import WebView frame = wx.Frame(None, -1, size=size) view = WebView.New(frame) view.SetPage(html, url) frame.Show() return frame
def __init__(self, *args, **kwds): wx.Frame.__init__(self, *args, **kwds) szr = wx.BoxSizer(wx.VERTICAL) self.SetSizer(szr) self._was_shown = False self._is_default_viewer = False self.viewer = None _import_error = None if (wx.Platform == '__WXMAC__'): try: from wx import webkit except ImportError as e: _import_error = str(e) else: self.viewer = webkit.WebKitCtrl(self, -1) self.Bind(webkit.EVT_WEBKIT_STATE_CHANGED, self.OnChangeState, self.viewer) self.Bind(webkit.EVT_WEBKIT_BEFORE_LOAD, self.OnBeforeLoad, self.viewer) elif (wx.Platform == '__WXMSW__'): try: from wx.html2 import WebView except ImportError as e: _import_error = str(e) else: self.viewer = WebView.New(self) if (self.viewer is None): # fallback (default on Linux) self.viewer = HtmlPanel(self) self._is_default_viewer = True szr.Add(self.viewer, 1, wx.EXPAND) self.SetupToolbar() self.statusbar = self.CreateStatusBar() if (wx.Platform != "__WXMSW__"): self.SetInitialSize((1024, 640)) #self.Bind(wx.EVT_WINDOW_CREATE, self.OnShow) # create keyboard shortcuts for zoom functions in toolbar if (wx.Platform == '__WXMAC__'): zoomInId = wx.NewId() zoomOutId = wx.NewId() zoomDefaultId = wx.NewId() self.Bind(wx.EVT_MENU, self.OnZoomIn, id=zoomInId) self.Bind(wx.EVT_MENU, self.OnZoomOut, id=zoomOutId) self.Bind(wx.EVT_MENU, self.OnZoomDefault, id=zoomDefaultId) self.accelerator_table = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('='), zoomInId), (wx.ACCEL_CTRL, wx.WXK_NUMPAD_ADD, zoomInId), (wx.ACCEL_CTRL, ord('-'), zoomOutId), (wx.ACCEL_CTRL, wx.WXK_NUMPAD_SUBTRACT, zoomOutId), (wx.ACCEL_CTRL, ord('0'), zoomDefaultId), (wx.ACCEL_CTRL, wx.WXK_NUMPAD0, zoomDefaultId) ]) self.SetAcceleratorTable(self.accelerator_table) self.zoom_counter = 0
def __init__(self, parent, *args, **kwargs): display_w, display_h = wx.DisplaySize() x = 0 y = 25 w = min(650, display_w) h = min(1000, display_h - y) EelbrainFrame.__init__(self, parent, pos=(x, y), size=(w, h), *args, **kwargs) self.webview = WebView.New(self)
def __init__(self, app: App): super(Frame, self).__init__(None) self.editor = TextCtrl(self, 101, style=TE_MULTILINE) self.stat: StatusBar = self.CreateStatusBar() self.stat.SetFieldsCount(2) self.stat.SetStatusWidths([-1, -5]) self.SetTitle(f"{BASETITLE} - *Untitled*") self.SetSize(720, 540) self.File: str = None self.changed = False menubar: MenuBar = MenuBar() edit_menu: Menu = Menu() file_menu: Menu = Menu() edit_menu.Append(1, "&Preview\tCtrl+P") edit_menu.Append(2, "Post") edit_menu.AppendSeparator() edit_menu.Append(7, "&Ruby\tCtrl+R") edit_menu.Append(9, "&Dotmarks\tCtrl+Shift+D") edit_menu.Append(8, "&Paragraph\tCtrl+Space") file_menu.Append(3, "&New\tCtrl+N") file_menu.Append(4, "&Open\tCtrl+Shift+O") file_menu.AppendSeparator() file_menu.Append(5, "&Save as\tCtrl+Shift+S") file_menu.Append(6, "&Save\tCtrl+S") menubar.Append(file_menu, "&File") menubar.Append(edit_menu, "&Edit") self.SetMenuBar(menubar) self.Bind(EVT_MENU, self.Preview, id=1) self.Bind(EVT_MENU, self.Post, id=2) self.Bind(EVT_MENU, self.New, id=3) self.Bind(EVT_MENU, self.Open, id=4) self.Bind(EVT_MENU, self.SaveAs, id=5) self.Bind(EVT_MENU, self.Save, id=6) self.Bind(EVT_MENU, self.SetRuby, id=7) self.Bind(EVT_MENU, self.SetParagraphSpaces, id=8) self.Bind(EVT_MENU, self.Dotmarks, id=9) self.pvframe = HideFrame(None, -1, "プレビュー") self.pvctrl: WebView = WebView.New(self.pvframe) self.pvctrl.SetCanFocus(False) self.pvframe.SetCanFocus(False) self.Bind(EVT_TEXT, self.Reload, id=101) app.SetTopWindow(self) self.application = app self.Show()
def __init__(self): self.loaded = False super().__init__(None) p = Panel(self) s = BoxSizer(VERTICAL) ts = BoxSizer(HORIZONTAL) ts.Add(StaticText(p, label='A&ddress'), 0, GROW) self.address = TextCtrl(p, style=TE_PROCESS_ENTER) self.address.Bind(EVT_TEXT_ENTER, self.on_enter) ts.Add(self.address, 1, GROW) s.Add(ts, 0, GROW) self.html = WebView.New(p) self.html.Bind(EVT_WEBVIEW_LOADED, self.on_load) self.html.Bind(EVT_WEBVIEW_ERROR, self.on_error) self.html.Bind(EVT_WEBVIEW_TITLE_CHANGED, self.on_title) s.Add(self.html, 1, GROW) p.SetSizerAndFit(s)
def __init__(self, session): wx.Frame.__init__(self, None, title="ChimeraX", size=(1000,700)) from wx.lib.agw.aui import AuiManager, AuiPaneInfo self.aui_mgr = AuiManager(self) self.aui_mgr.SetManagedWindow(self) from .graphics import GraphicsWindow # View is a base class of Graphics Window self.graphics_window = g = GraphicsWindow(session, self) self.view = g.view self.aui_mgr.AddPane(g, AuiPaneInfo().Name("GL").CenterPane()) session.main_window = self # needed for ToolWindow init from ..tool_api import ToolWindow self._text_window = ToolWindow("Messages", "General", session, destroy_hides=True) from wx.html2 import WebView, EVT_WEBVIEW_NAVIGATING self._text = WebView.New(self._text_window.ui_area, size=(250,500)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self._text, 1, wx.EXPAND) self._text_window.ui_area.SetSizerAndFit(sizer) self.text_id = None self._text_window.manage("right") self._text_window.shown = False self.Bind(EVT_WEBVIEW_NAVIGATING, self.OnWebViewNavigating, self._text) self._anchor_cb = None self.status_bar = self.CreateStatusBar(3, wx.STB_SIZEGRIP| wx.STB_SHOW_TIPS|wx.STB_ELLIPSIZE_MIDDLE|wx.FULL_REPAINT_ON_RESIZE) self.status_bar.SetStatusWidths([-24, -30, -2]) self.status_bar.SetStatusText("Status", 0) self.status_bar.SetStatusText("Welcome to ChimeraX", 1) self.status_bar.SetStatusText("", 2) self._shortcuts_enabled = False from .cmd_line import CmdLine self._command_line = CmdLine(session) self.Bind(wx.EVT_CLOSE, self.OnClose) self.SetDropTarget(_FileDrop(session))
def __init__(self, parent, title): super().__init__(parent, wx.ID_ANY, title, size=(1200, 700)) bSizer9 = wx.BoxSizer(wx.VERTICAL) self._browser = WebView.New(self) bSizer9.Add(self._browser, 1, wx.ALL | wx.EXPAND, 5) # widget, proportion, flags, border bSizer8 = wx.BoxSizer(wx.HORIZONTAL) for i in range(5): btn = wx.Button(self, wx.ID_OK, f"Btn{i}", wx.DefaultPosition, wx.DefaultSize, 0) bSizer8.Add(btn, 0, wx.ALL | wx.EXPAND, 5) self.Bind(wx.EVT_BUTTON, self.OnButtonClick, btn) bSizer9.Add(bSizer8, 0) self.SetSizer(bSizer9) self.Layout() # self._browser.LoadURL('http://pynsource.com') self._browser.LoadURL('http://google.com') self.Show()
def __init__(self, username, password, host, port, clientsocket): wx.Frame.__init__(self, None, title=__appname__ + " " + __version__) # Making args class-namespaced self.host = host self.port = port self.username = username self.password = password self.clientsocket = clientsocket # Path variables self.userdir = appdata + self.username + "\\" self.dirs = { "avatars": appdata + "avatars", "chatlogs": self.userdir + "chatlogs", "chatlogs_server": lambda: self.userdir + "chatlogs\\" + self.host, "thumbs": self.userdir + "thumbs" } self.paths = { "avatar": self.dirs["avatars"] + "\\" + self.username + ".png", "chatlog": lambda roomname: self.dirs["chatlogs_server"]() + "\\" + roomname + ".html", "contacts": self.userdir + "contacts.txt", "lastmsg": self.userdir + "lastmsg.txt", "lastupdate": self.userdir + "lastupdate.txt", "log": self.userdir + "log.log", "online": self.userdir + "online.html", "rooms": self.userdir + "rooms.txt", "servers": self.userdir + "servers.txt", "settings": self.userdir + "settings.txt" } # Misc variables self.new_server = [None, None] self.currentroom = "GLOBAL CHAT" self.roomaccess = [] self.seconds = {} self.roomtypes = {} self.usercolors = {} self.datastream = Queue() # self.commands = ["afk", "die", "exit", "help"] self.colordata = self.roomhittest = None self.disconnected = self.quitting = self.reconnecting = False self.autoafk = True self.banned_html = ["body", "caption", "form", "frame", "head", "html", "iframe", "link", "script", "style", \ "table", "tbody", "td", "tfoot", "thead", "tr"] # Loading values file_room = self.paths["rooms"] self.chatroomdata = FILE_LOAD(file_room, {}) self.serverdata = FILE_LOAD(self.paths["servers"], {self.host: port}) self.lastupdate = FILE_LOAD(self.paths["lastupdate"], {self.host: time()}) # Getting startup information from server self.userdata = eval(RECVMSG(self.clientsocket)) # Checking if room file needs to be updated if (self.host not in self.lastupdate) or (self.host not in self.chatroomdata) or \ (self.userdata["mtime-rooms"] > self.lastupdate[self.host] + 0.1): self._try_send("SEND-ROOMS") self.chatroomdata[self.host] = eval(RECVMSG(self.clientsocket)) FILE_WRITE(file_room, self.chatroomdata) self.lastupdate[self.host] = time() FILE_WRITE(self.paths["lastupdate"], self.lastupdate) else: self._try_send("DONT-SEND-ROOMS") self.chatroomdata = eval(FILE_READ(file_room)) # Managing settings settings = self.paths["settings"] action_settings = self.startup_data("settings") if action_settings == "FETCH": response = RECVMSG(self.clientsocket) if response == "NO-SETTINGS": self.settings = defaultsettings self._try_send(self.settings) else: self.settings = eval(response) self.new_settings() FILE_WRITE(settings, self.settings) else: self.settings = eval(FILE_READ(settings)) self.new_settings() if self.userdata["mtime-settings"] == None: self._try_send(self.settings) self.initsettings = deepcopy(self.settings) self.afkinit = self.afktimer = self.settings["afkinterval"] # Creating structure of "seconds" variable for server in self.chatroomdata: self.seconds[server] = {} self.seconds[server]["GLOBAL CHAT"] = [] for room in self.GET_ROOMTYPE("public").keys() + self.GET_ROOMTYPE("private").keys(): self.seconds[server][room] = [] # Setting up folders and files DIR_CREATE(self.dirs["avatars"]) DIR_CREATE(self.dirs["chatlogs"]) DIR_CREATE(self.dirs["chatlogs_server"]()) DIR_CREATE(self.dirs["thumbs"]) FILE_WRITE(self.paths["chatlog"](self.currentroom), HTML_CHAT) FILE_WRITE(self.paths["online"], HTML_SESSION) # Panel self.panel = wx.Panel(self) # Popup menu: Colors self.colorpopup = wx.Menu() colors = ["white", "grey", "black", "red", (255, 127, 0), "yellow", "green", "cyan", "blue", "navy", "purple"] for color in colors: coloritem = wx.MenuItem(self.colorpopup, wx.ID_ANY, " ") coloritem.SetBackgroundColour(color) self.colorpopup.AppendItem(coloritem) self.Bind(wx.EVT_MENU, self.set_color, coloritem) self.colorpopup.AppendSeparator() colorwheel = self.colorpopup.Append(wx.ID_ANY, "Color wheel...") self.Bind(wx.EVT_MENU, self.color_dialog, colorwheel) # Popup menu: Rooms self.roommenu = wx.Menu() room_delete = wx.MenuItem(self.roommenu, wx.ID_ANY, "Delete room") self.roommenu.AppendItem(room_delete) self.Bind(wx.EVT_MENU, self.delete_room, room_delete) # Menu bar menubar = wx.MenuBar() menu_settings = wx.Menu() menu_settings_afk = menu_settings.Append(wx.ID_ANY, "AFK...") menu_settings_avatar = menu_settings.Append(wx.ID_ANY, "Avatar...") menu_settings_emotes = menu_settings.Append(wx.ID_ANY, "Emotes...") if basename(split(getcwd())[0]) == "CharlieChat Dev": menu_settings_messages = menu_settings.Append(wx.ID_ANY, "Messages...") # @UnusedVariable menu_settings_sounds = menu_settings.Append(wx.ID_ANY, "Sounds...") # @UnusedVariable menu_settings_text = menu_settings.Append(wx.ID_ANY, "Text...") # @UnusedVariable menu_account = wx.Menu() menu_account_switchuser = menu_account.Append(wx.ID_ANY, "Switch user...") menu_account_register = menu_account.Append(wx.ID_ANY, "Register new user...") menu_account_changepass = menu_account.Append(wx.ID_ANY, "Change password...") menu_account_delete = menu_account.Append(wx.ID_ANY, "Delete account") menu_connection = wx.Menu() self.menu_connection_disconnect = menu_connection.Append(wx.ID_ANY, "Disconnect") menu_connection_restart = menu_connection.Append(wx.ID_ANY, "Restart connection") menubar.Append(menu_settings, "Settings") menubar.Append(menu_account, "Account") menubar.Append(menu_connection, "Connection") self.SetMenuBar(menubar) # Toolbar self.toolbar = self.CreateToolBar() self.tool_sounds = self.toolbar.AddCheckLabelTool(1, "Seconds", wx.Bitmap("images/speaker.png")) self.tool_seconds = self.toolbar.AddCheckLabelTool(2, "Sounds", wx.Bitmap("images/seconds.png")) self.tool_afk = self.toolbar.AddCheckLabelTool(3, "AFK", wx.Bitmap("images/afk.png")) self.toolbar.Realize() self.toolbar.SetToolShortHelp(1, "Toggle sounds") self.toolbar.SetToolShortHelp(2, "Toggle display of seconds in chat window") self.toolbar.SetToolShortHelp(3, "Toggle whether you are shown as AFK or not") # Sizers box = wx.BoxSizer() grid = wx.FlexGridSizer(2, 1, 10, 10) header = wx.FlexGridSizer(1, 2, 10, 10) windows = wx.FlexGridSizer(1, 3, 10, 10) chat = wx.FlexGridSizer(0, 1, 10, 10) chatbuttons = wx.FlexGridSizer(1, 2, 10, 10) roomsettings = wx.FlexGridSizer(5, 1, 10, 10) conversation = wx.GridSizer(1, 0, 5, 5) # Widgets webcam = wx.ToggleButton(self.panel, label="Webcam") voice = wx.ToggleButton(self.panel, label="Voice") self.chattext = WebView.New(self.panel) self.add_msg("", HTML_WELCOME, now(), "black", self.currentroom, False) FILE_WRITE(self.paths["chatlog"](self.currentroom), HTML_LINE, "a") self.chatinput = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE | wx.TE_PROCESS_ENTER) self.send = wx.Button(self.panel, label="SEND", size=(-1, 50)) colorbutton = wx.BitmapButton(self.panel, bitmap=wx.Image("images/colorwheel.png", \ wx.BITMAP_TYPE_PNG).ConvertToBitmap(), size=(50, 50)) usercontainer = wx.Notebook(self.panel) users_online = PanelUsermode(self, usercontainer, self.paths["online"]) self.users_contacts = PanelUsermode(self, usercontainer, "contacts") usercontainer.AddPage(users_online, "Online") usercontainer.AddPage(self.users_contacts, "Contacts") self.conv_info = wx.StaticText(self.panel, label=self.host + ": " + self.username) self.reconnect = wx.StaticText(self.panel, label="Reconnecting") self.servers = wx.ListBox(self.panel, style=wx.LB_SINGLE) server_add = wx.Button(self.panel, label="Add server") self.chatrooms = wx.TreeCtrl(self.panel, style=wx.TR_HAS_BUTTONS | wx.TR_HIDE_ROOT | \ wx.TR_ROW_LINES | wx.TR_MULTIPLE) room_search = wx.SearchCtrl(self.panel) room_add = wx.Button(self.panel, label="Add room") # Fonts font = self.conv_info.GetFont() font.SetPointSize(14) self.conv_info.SetFont(font) font.SetPointSize(12) font.SetWeight(wx.BOLD) self.send.SetFont(font) font = self.chatinput.GetFont() font.SetPointSize(11) self.chatinput.SetFont(font) font = self.reconnect.GetFont() font.SetWeight(wx.BOLD) self.reconnect.SetFont(font) # Add servers to list widget if self.host not in self.serverdata: self.serverdata[self.host] = self.port FILE_WRITE(self.paths["servers"], self.serverdata) self.servers.Append(self.host) for lbl_server in self.serverdata: self.servers.Append(lbl_server) self.servers.SetSelection(self.servers.GetItems().index(self.host)) # Global room root = self.chatrooms.AddRoot("") globalroom = self.chatrooms.AppendItem(root, "GLOBAL CHAT") self.chatrooms.SetItemBold(globalroom) # Loop: roomtypes for lbl_roomtype in self.GET_SERVER(): roomtype = self.chatrooms.AppendItem(root, lbl_roomtype.title() + " rooms") self.chatrooms.SetItemBold(roomtype) self.roomtypes[lbl_roomtype] = roomtype # Loop: rooms for lbl_room in self.GET_ROOMTYPE(lbl_roomtype): self.chatrooms.AppendItem(roomtype, lbl_room) # Update HTML for each room FILE_WRITE(self.paths["chatlog"](lbl_room), HTML_CHAT) self.chatrooms.ExpandAll() self.chatrooms.SelectItem(globalroom) # Add widgets to sizers conversation.AddMany([webcam, voice]) chat.AddMany([conversation, (self.chattext, 1, wx.EXPAND), (self.chatinput, 1, wx.EXPAND), (chatbuttons, 1, wx.EXPAND)]) header.AddMany([self.conv_info, (self.reconnect, 0, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM)]) chatbuttons.AddMany([(self.send, 1, wx.EXPAND), colorbutton]) roomsettings.AddMany([(self.servers, 1, wx.EXPAND), (server_add, 1, wx.EXPAND), (self.chatrooms, 1, wx.EXPAND), \ (room_search, 1, wx.EXPAND), (room_add, 1, wx.EXPAND)]) windows.AddMany([(usercontainer, 1, wx.EXPAND), (chat, 1, wx.EXPAND), (roomsettings, 1, wx.EXPAND)]) grid.AddMany([(header, 1, wx.EXPAND), (windows, 1, wx.EXPAND)]) box.Add(grid, 1, wx.ALL | wx.EXPAND, 20) self.panel.SetSizer(box) # Define growables and ratios chat.AddGrowableRow(1, 10) # Chat height chat.AddGrowableRow(2, 2) # Input height chat.AddGrowableCol(0) # Chat width windows.AddGrowableRow(0) # Users height windows.AddGrowableCol(0, 3) # Users width windows.AddGrowableCol(1, 10) # Chat + input + buttons width windows.AddGrowableCol(2, 1) # Chatrooms width roomsettings.AddGrowableCol(0) # Chatrooms width roomsettings.AddGrowableRow(0, 1) # Chatrooms height roomsettings.AddGrowableRow(2, 5) # Chatrooms height chatbuttons.AddGrowableCol(0) # Send button width header.AddGrowableCol(1) # Reconnect text grid.AddGrowableCol(0) # Conversation info width grid.AddGrowableRow(1) # Widgets height # Window size self.SetClientSize((1050, 518)) self.SetMinSize((454, 413)) # Binding events self.Bind(wx.EVT_MENU, self.settings_afk, menu_settings_afk) self.Bind(wx.EVT_MENU, self.settings_avatar, menu_settings_avatar) self.Bind(wx.EVT_MENU, self.settings_emotes, menu_settings_emotes) self.Bind(wx.EVT_MENU, self.switch_user, menu_account_switchuser) self.Bind(wx.EVT_MENU, self.register_user, menu_account_register) self.Bind(wx.EVT_MENU, self.change_password, menu_account_changepass) self.Bind(wx.EVT_MENU, self.delete_user, menu_account_delete) self.Bind(wx.EVT_MENU, self.disconnect, self.menu_connection_disconnect) self.Bind(wx.EVT_MENU, self.switch_server, menu_connection_restart) self.Bind(wx.EVT_TOOL, self.toggle_seconds, self.tool_seconds) self.Bind(wx.EVT_TOOL, self.toggle_sounds, self.tool_sounds) self.Bind(wx.EVT_TOOL, self.toggle_afk, self.tool_afk) self.Bind(wx.EVT_LISTBOX, self.switch_server, self.servers) self.Bind(wx.EVT_BUTTON, self.add_server, server_add) self.Bind(wx.EVT_TREE_SEL_CHANGING, self.switch_room, self.chatrooms) self.chatrooms.Bind(wx.EVT_RIGHT_DOWN, self.popup_room) self.Bind(wx.EVT_TEXT, self.search_rooms, room_search) room_search.Bind(wx.EVT_KEY_DOWN, ERASE_TEXT) self.Bind(wx.EVT_BUTTON, self.add_room, room_add) self.Bind(wx.EVT_TOGGLEBUTTON, self.toggle_webcam, webcam) self.Bind(wx.EVT_TOGGLEBUTTON, self.toggle_voice, voice) self.Bind(EVT_WEBVIEW_NAVIGATING, self.url_navigate, self.chattext) self.Bind(wx.EVT_BUTTON, self.popup_color, colorbutton) self.chatinput.Bind(wx.EVT_KEY_DOWN, self.chat_hotkeys) self.Bind(wx.EVT_BUTTON, self.msg_send, self.send) self.Bind(wx.EVT_CLOSE, self.quit) # Hiding reconnect (only show when actually reconnecting) self.reconnect.Hide() # self.contactlist.Hide() # Set focus to text input (start writing instantly) self.chatinput.SetFocus() # Applying settings self.apply_settings() self.chatinput.SetForegroundColour(self.settings["color"]) # Loading contacts action_contacts = self.startup_data("contacts") if action_contacts == "FETCH": response = RECVMSG(self.clientsocket) if response == "NO-CONTACTS": if not isfile(self.paths["contacts"]): with open(self.paths["contacts"], "w"): pass with open(self.paths["contacts"]) as contactfile: self._try_send(contactfile.read()) else: with open(self.paths["contacts"], "w") as contactfile: contactfile.write(response) else: if self.userdata["mtime-contacts"] == None: with open(self.paths["contacts"]) as contactfile: self._try_send(contactfile.read()) self.load_contacts() # Starting threads self.thread_stream = MultiThread(self.data_actions) self.thread_recv = MultiThread(self.msg_recv) self.thread_afk = MultiThread(self.afk_countdown) self.thread_stream.daemon = True self.thread_recv.daemon = True self.thread_afk.daemon = True self.thread_stream.start() self.thread_recv.start() if self.settings["autoafk"]: self.thread_afk.start() self.init_voice() MultiThread(self.empty_voicebuffer).start() # Load timestamp of last message (determine if log file needs new date header) self.lastmsg = FILE_LOAD(self.paths["lastmsg"], "'" + now().split(" ")[0] + "'") # Add users to list of connected users self.add_user(self.username, self.userdata["mtime-avatar"]) for user in self.userdata["users"]: self.add_user(user, self.userdata["users"][user]["mtime-avatar"], user in self.userdata["afks"], \ self.userdata["users"][user]["color"]) # Set icon (REMOVE set_appname WHEN .exe) set_appname() self.SetIcon(wx.Icon("images/testicon.ico")) self.hook_establish() # Showing window self.Center() self.Show()
def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title, size=(1024, 768)) web_view = WebView.New(self) web_view.LoadURL("http://www.mryu.top/")
def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title, size=(1000, 800)) WebView.New(self).LoadURL(wangzhi.get())
def __init__(self, title): wx.Frame.__init__(self, None, -1, title, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER) mainBoxSizer = wx.BoxSizer(wx.HORIZONTAL) scrollFlexSizer = wx.FlexGridSizer(100, 1, 10, 0) scrollPanel = scrolled.ScrolledPanel(self, -1) infoFlexSizer = wx.FlexGridSizer(2, 1, 0, 0) infoPanel = scrolled.ScrolledPanel(self, -1) clickBox1 = wx.CheckBox(scrollPanel, label="Pornhub") clickBox2 = wx.CheckBox(scrollPanel, label="QQ") clickBox3 = wx.CheckBox(scrollPanel, label="WeChat") clickBox4 = wx.CheckBox(scrollPanel, label="NetEase") scrollFlexSizer.AddMany([ (clickBox1, 0, wx.SHAPED), (clickBox2, 0, wx.SHAPED), (clickBox3, 0, wx.SHAPED), (clickBox4, 0, wx.SHAPED), ]) scrollFlexSizer.AddGrowableCol(0) scrollPanel.SetMaxSize((200, 500)) scrollPanel.SetMinSize((200, 500)) scrollPanel.SetSizerAndFit(scrollFlexSizer) scrollPanel.SetAutoLayout(1) scrollPanel.SetupScrolling() # textBox1 = wx.TextCtrl(infoPanel, -1, size=(600, 400), style=wx.TE_READONLY | wx.TE_MULTILINE) self.textBox2 = wx.TextCtrl(infoPanel, -1, size=(600, 100), style=wx.TE_MULTILINE | wx.TE_RICH2 | wx.TE_READONLY) wv = WebView.New(infoPanel, size=(600, 400)) wv.LoadURL("https://www.baidu.com/") # textBox1.write("hello\nworld") # textBox1.Clear() self.textBox2.Bind(wx.EVT_TEXT_ENTER, self.onTextEnter) infoFlexSizer.AddMany([ # (textBox1, 0, wx.SHAPED), (wv, 0, wx.SHAPED), (self.textBox2, 0, wx.SHAPED), ]) infoPanel.SetSizerAndFit(infoFlexSizer) infoPanel.SetAutoLayout(1) infoPanel.SetupScrolling() mainBoxSizer.Add(scrollPanel, 1, wx.ALIGN_LEFT, wx.ALL) mainBoxSizer.Add(infoPanel, 4, wx.ALIGN_RIGHT, wx.ALL) self.SetSizerAndFit(mainBoxSizer) self.SetSize((700, 500)) self.Bind(wx.EVT_CHECKBOX, self.onChecked)
def _create_web_view(parent): """Create a web view.""" web_view = WebView.New(parent) web_view.SetEditable(False) web_view.EnableContextMenu(False) return web_view
def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title, size=(1024, 768)) web_view = WebView.New(self) web_view.LoadURL("https://huang825172.info")
def __init__(self, parent): wx.Panel.__init__(self, parent) self.browser = WebView.New(self) bsizer = wx.BoxSizer() bsizer.Add(self.browser, 1, wx.EXPAND) self.SetSizerAndFit(bsizer)
def _InitUI( self ): """Builds this UI component. Obviously, must be called in the UI thread. """ # -- Header # -- self.headerCtrl = wx.TextCtrl( self, wx.ID_ANY, style = wx.BORDER_NONE | wx.TE_DONTWRAP | wx.TE_READONLY ) self.headerCtrl.SetBackgroundColour( self.GetBackgroundColour() ) # -- Splitter window # -- self.splitterWindow = wx.SplitterWindow( self, wx.ID_ANY, style = wx.SP_3DSASH | wx.SP_LIVE_UPDATE ) # -- Table # -- self.listCtrl = ulc.UltimateListCtrl( self.splitterWindow, -1, agwStyle = #wx.LC_HRULES | wx.LC_REPORT | wx.LC_VRULES | #wx.LC_SINGLE_SEL | ulc.ULC_HRULES | ulc.ULC_REPORT | ulc.ULC_VRULES | ulc.ULC_SINGLE_SEL | ulc.ULC_HAS_VARIABLE_ROW_HEIGHT ) ##x self.listCtrl.SetFont( self.valueFont ) # -- Attribute view # -- #x self.attrView = HtmlWindow( #x self.splitterWindow, wx.ID_ANY, #x style = wx.BORDER_SIMPLE | wx.html.HW_SCROLLBAR_AUTO #x ) if WEB_VIEW: self.attrView = WebView.New( self.splitterWindow ) self.attrView.SetBackgroundColour( self.GetBackgroundColour() ) else: self.attrView = HtmlWindow( self.splitterWindow ) # -- Lay Out # -- self.listCtrl.Bind( wx.EVT_LIST_ITEM_SELECTED, self._OnItemSelected ) self.splitterWindow.SplitHorizontally( self.listCtrl, self.attrView, -80 ) sizer = wx.BoxSizer( wx.VERTICAL ) sizer.Add( self.headerCtrl, 0, wx.ALIGN_CENTRE_VERTICAL | wx.ALIGN_LEFT | wx.ALL | wx.EXPAND, 2 ) # sizer.Add( self.listCtrl, 3, wx.ALIGN_LEFT | wx.ALIGN_TOP | wx.EXPAND, 0 ) # sizer.Add( # self.attrView, 1, # wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_TOP | wx.EXPAND, 1 # ) sizer.Add( self.splitterWindow, 1, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_TOP | wx.EXPAND, 4 ) self.SetAutoLayout( True ) self.SetSizer( sizer ) # -- Events # -- self.listCtrl.Bind( wx.EVT_LIST_ITEM_SELECTED, self._OnItemSelected ) self.Bind( wx.EVT_CONTEXT_MENU, self._OnContextMenu )
def __init__(self, parent, title): super().__init__(parent, wx.ID_ANY, title, size=(600, 500)) self._browser = WebView.New(self) self._browser.LoadURL('https://jenyay.net') self.Show()
def __init__(self, parent, title): super().__init__(parent, wx.ID_ANY, title, size=(600, 500)) self._browser = WebView.New(self) self._browser.SetPage(HTML, '.') self.Show()