def __init__(self): UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); size = Dimension(800, 800) self.setPreferredSize(size) screenSize = Toolkit.getDefaultToolkit().getScreenSize(); self.setLocation(screenSize.getSize().width/2 - size.width/2, 100) self.setTitle("bashED Terminal HQ EXTREME"); self.setUndecorated(True) self.getRootPane().setOpaque(False) #self.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); self.setBackground(Color(0,128,0, 198)) #j = JDesktopPane() #j.setOpaque(False) self.setLayout(None) self.setIconImage(ImageIcon('bin/gui/media/' + "icon.png").getImage()) mp = MainPanel() self.add(mp) mp.setBounds(0, 0, size.width, size.height) imageTest = ImageIcon('bin/gui/media/' + "image.png") imageTestLabel = JLabel(imageTest) self.add(imageTestLabel) imageTestLabel.setBounds(0, 0, size.width, size.height) #self.getContentPane().add(mp) #self.getContentPane().add(JLabel("Iglo")) bb = BorderFactory.createLineBorder(Color.BLACK, 5) bw1 = BorderFactory.createLineBorder(Color.WHITE, 1) bw2 = BorderFactory.createLineBorder(Color.WHITE, 1) mp.setBorder( BorderFactory.createCompoundBorder( bw1, BorderFactory.createCompoundBorder(bb, bw2) )) #make the window viewable self.defaultCloseOperation=JFrame.EXIT_ON_CLOSE self.pack() self.setVisible(True)
def register(self,uid): msg=self.msg.packMsg('REGISTER',uid) print("Sending register msg...") self.transport.write(msg) print("Done") self.mainPanel=MainPanel(self) self.mainPanel.run() if isinstance(self.mainPanel,MainPanel): self.getCustomGroups()
def __init__(self): UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) size = Dimension(800, 800) self.setPreferredSize(size) screenSize = Toolkit.getDefaultToolkit().getScreenSize() self.setLocation(screenSize.getSize().width / 2 - size.width / 2, 100) self.setTitle("bashED Terminal HQ EXTREME") self.setUndecorated(True) self.getRootPane().setOpaque(False) #self.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); self.setBackground(Color(0, 128, 0, 198)) #j = JDesktopPane() #j.setOpaque(False) self.setLayout(None) self.setIconImage(ImageIcon('bin/gui/media/' + "icon.png").getImage()) mp = MainPanel() self.add(mp) mp.setBounds(0, 0, size.width, size.height) imageTest = ImageIcon('bin/gui/media/' + "image.png") imageTestLabel = JLabel(imageTest) self.add(imageTestLabel) imageTestLabel.setBounds(0, 0, size.width, size.height) #self.getContentPane().add(mp) #self.getContentPane().add(JLabel("Iglo")) bb = BorderFactory.createLineBorder(Color.BLACK, 5) bw1 = BorderFactory.createLineBorder(Color.WHITE, 1) bw2 = BorderFactory.createLineBorder(Color.WHITE, 1) mp.setBorder( BorderFactory.createCompoundBorder( bw1, BorderFactory.createCompoundBorder(bb, bw2))) #make the window viewable self.defaultCloseOperation = JFrame.EXIT_ON_CLOSE self.pack() self.setVisible(True)
class Client(Int32StringReceiver): def __init__(self): self.mainPanel=None self.uid=None self.msgHandler={ 'CHAT' : self.chatMsg, 'CUSTOM_USER_LOGIN' : self.customLogin, 'CUSTOM_GROUPS' : self.customGroups, } def customLogin(self,msg): print("Recv login response ...") print(msg) ErrorCode=self.msg.getValue(msg,'ErrorCode') UserID=self.msg.getValue(msg,'UserID') self.uid=UserID if ErrorCode == 0 : self.factory.loginWindow.destroy() self.register(self.uid) def register(self,uid): msg=self.msg.packMsg('REGISTER',uid) print("Sending register msg...") self.transport.write(msg) print("Done") self.mainPanel=MainPanel(self) self.mainPanel.run() if isinstance(self.mainPanel,MainPanel): self.getCustomGroups() def getCustomGroups(self): msg=self.msg.packMsg('GET_CUSTOM_GROUPS') print("Sending get-custom-groups msg...") self.transport.write(msg) print("Done") def customGroups(self,msg): GroupName=self.msg.getValue(msg,'GroupName') Users=self.msg.getValue(msg,'Users') user_list=list() if Users is not None: for user in Users: uname=user['DisplayName'] uid=user['UserGuid'] user_list.append((uname,uid)) print GroupName,user_list if isinstance(self.mainPanel,MainPanel): self.mainPanel.update(GroupName,user_list) else: pass def chatMsg(self,msg): RecvUid=self.msg.getValue(msg,'RecvGuid') SendUid=self.msg.getValue(msg,'SendGuid') SendTime=self.msg.getValue(msg,'Created') MsgContent=self.msg.getValue(msg,'Body') print msg #try: # self.mainPanel.user_map[SendUid].recvMsg(SendUid,MsgContent,SendTime) #except KeyError: # print 'users window is not open...' def errHandle(self,msg): print msg def lengthLimitExceeded(self,length): print length return def connectionMade(self): print("connect with server %s") % self.transport.getPeer().host def stringReceived(self, msg): msgType=self.msg.getValue(msg,'Type') msgHandler=self.msgHandler.get(msgType,self.errHandle) msgHandler(msg) return
from tkinter import * from mainPanel import MainPanel app = Tk() root = MainPanel(app) # Execution of the programme app.mainloop()