zdravim mam problem s chatem
# -*- coding: utf-8 -*-
###########################################################################
## Python code generated with wxFormBuilder (version Feb 9 2012)
## http://www.wxformbuilder.org/
##
## PLEASE DO "NOT" EDIT THIS FILE!
###########################################################################
import wx
import wx.xrc
import time
import fakelan
import socket
###########################################################################
## Class HlavniOknoFrame
###########################################################################
class HlavniOknoFrame ( wx.Frame ):
def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"J-LIM", pos = wx.DefaultPosition, size = wx.Size( 300,150 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
bSizer4 = wx.BoxSizer( wx.VERTICAL )
self.m_panel2 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
bSizer5 = wx.BoxSizer( wx.VERTICAL )
bSizer6 = wx.BoxSizer( wx.HORIZONTAL )
self.OknaChatu=[]
self.CisloOkna=-1
self.SlovnikOken={}
self.VyberKamaradaChoiceChoices = fakelan.lan()
self.VyberKamaradaChoice = wx.Choice( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.VyberKamaradaChoiceChoices, 0 )
self.VyberKamaradaChoice.SetSelection( 0 )
self.vybranej=self.VyberKamaradaChoiceChoices[0]
bSizer6.Add( self.VyberKamaradaChoice, 1, wx.ALL|wx.EXPAND, 5 )
bSizer5.Add( bSizer6, 1, wx.EXPAND|wx.TOP, 5 )
bSizer7 = wx.BoxSizer( wx.HORIZONTAL )
self.PripojitButton = wx.Button( self.m_panel2, wx.ID_ANY, u"Připojit", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer7.Add( self.PripojitButton, 1, wx.ALL|wx.EXPAND, 5 )
self.ObnovitButton = wx.Button( self.m_panel2, wx.ID_ANY, u"Obnovit", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer7.Add( self.ObnovitButton, 1, wx.ALL|wx.EXPAND, 5 )
bSizer5.Add( bSizer7, 1, wx.EXPAND, 5 )
bSizer9 = wx.BoxSizer( wx.HORIZONTAL )
self.PosledniObnoveniLabel = wx.StaticText( self.m_panel2, wx.ID_ANY, u"poslední obnovení: "+ time.asctime( time.localtime(time.time()) ), wx.DefaultPosition, wx.DefaultSize, 0 )
self.PosledniObnoveniLabel.Wrap( -1 )
bSizer9.Add( self.PosledniObnoveniLabel, 1, wx.ALL|wx.EXPAND, 5 )
bSizer5.Add( bSizer9, 0, 0, 5 )
self.m_panel2.SetSizer( bSizer5 )
self.m_panel2.Layout()
bSizer5.Fit( self.m_panel2 )
bSizer4.Add( self.m_panel2, 1, wx.EXPAND, 5 )
self.SetSizer( bSizer4 )
self.Layout()
self.Centre( wx.BOTH )
# Connect Events
self.PripojitButton.Bind( wx.EVT_BUTTON, self.OnPripojitButton )
self.ObnovitButton.Bind( wx.EVT_BUTTON, self.OnObnovitButton )
self.VyberKamaradaChoice.Bind( wx.EVT_CHOICE, self.OnChoice )
def __del__( self ):
pass
def PosledniObnoveniLabelNastaveni( self ):
cas = time.asctime( time.localtime(time.time()) )
text=u"poslední obnovení: "+ cas
self.PosledniObnoveniLabel.SetLabel(text)
def VyberKamaradaChoiceChoicesNastaveni( self ):
self.VyberKamaradaChoiceChoices=[]
self.VyberKamaradaChoiceChoices=fakelan.lan()
def OnChoice( self, event ):
self.vybranej = self.VyberKamaradaChoiceChoices[self.VyberKamaradaChoice.GetCurrentSelection()]
def OnPripojitButton( self, event ):
if self.SlovnikOken.has_key(self.vybranej):
pass
else:
self.CisloOkna=self.CisloOkna+1
self.SlovnikOken[self.vybranej]=self.CisloOkna
self.OknaChatu.append(ChatS(None,self.vybranej))
self.OknaChatu[self.CisloOkna].Show()
def OnObnovitButton( self, event ):
self.PosledniObnoveniLabelNastaveni()
self.VyberKamaradaChoiceChoicesNastaveni()
def Prijem( self, kamarad, zprava):
if self.SlovnikOken.has_key(kamarad):
self.CisloOkna=self.SlovnikOken[kamarad]
self.OknaChatu[self.CisloOkna].PrichoziTextCtrl.WriteText(zprava)
else:
self.CisloOkna=self.CisloOkna+1
self.SlovnikOken[kamarad]=self.CisloOkna
self.OknaChatu.append(ChatS(None,kamarad))
self.OknaChatu[self.CisloOkna].Show()
self.OknaChatu[self.CisloOkna].PrichoziTextCtrl.WriteText(zprava)
class ChatS ( wx.Frame ):
def __init__( self, parent, kamarad):
self.kamarad=kamarad
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"chat s "+ kamarad, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
bSizer4 = wx.BoxSizer( wx.VERTICAL )
self.PrichoziTextCtrl = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE|wx.TE_READONLY )
bSizer4.Add( self.PrichoziTextCtrl, 1, wx.EXPAND|wx.ALL, 5 )
bSizer16 = wx.BoxSizer( wx.HORIZONTAL )
self.OdchoziTextCtrl = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE )
bSizer16.Add( self.OdchoziTextCtrl, 1, wx.ALL|wx.EXPAND, 5 )
bSizer17 = wx.BoxSizer( wx.VERTICAL )
self.OdeslatButton = wx.Button( self, wx.ID_ANY, u"Odeslat", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer17.Add( self.OdeslatButton, 1, wx.ALL, 5 )
bSizer16.Add( bSizer17, 0, wx.EXPAND, 5 )
bSizer4.Add( bSizer16, 1, wx.EXPAND, 5 )
self.SetSizer( bSizer4 )
self.Layout()
self.Centre( wx.BOTH )
# Connect Events
self.OdeslatButton.Bind( wx.EVT_BUTTON, self.OnOdeslat )
self.Bind( wx.EVT_CLOSE, self.OnClose )
def __del__( self ):
pass
# Virtual event handlers, overide them in your derived class
def OnOdeslat( self, event ):
event.Skip()
#HlavniOknoVar.Prijem('ondra','ahoj')
for x in range(1000):
print "ahoj"
def OnClose( self, event ):
del HlavniOknoVar.SlovnikOken[self.kamarad]
self.Destroy()
jlim = wx.App()
HlavniOknoVar = HlavniOknoFrame(None)
HlavniOknoVar.Show()
jlim.MainLoop()
potreboval bych aby se na zacatku spustil dalsi proces ktery by kontroloval v nekonecne smycce jestli nepisla zprava a pote ji zapsal do prislusneho okna
me napadlo ze by ten novej proces mel pristup k promenym tohodle procesu a pak by to tam zapsal pomoci HlavniOknoVar.Prijem('jmeno kamarada','zprava') ale nevim jak na to
predem dik za odpoved