I'm having trouble making a round button and making it look good.
I need help trying to make a tkinter chat that looks as close as it can to a apple window (mac os). I already got all the sockets done on a other file i just need to make it look better. Here's is my code so far:
from tkinter import *
import tkinter as tk
root=Tk()
root.title('Chat server')
root.geometry("600x600")
#####
####
person = input('Who are you chatting with: ')
label = Label (root, text='Chat with ' + person )
label.grid(row=2,column=1)
frame=Frame(root, width=600, height=600, bg='blue')
frame.grid(row=3,column=1)
root.mainloop()
If you want the sockets code:
server:
import socket
from tkinter import *
root=Tk()
root.title('Chat server')
root.geometry("600x600")
frame=Frame(root, width=600, height=200, bg='blue')
s=socket.socket()
print('Socket created')
port=12345
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,1)
s.bind(('',port))
print("socket bound to %s" %(port))
history=[]
while True:
s.listen(5)
print("socket is listening")
while True:
g, addr = s.accept()
print('Got connection from', addr)
print('Connected')
break
while True:
x = input('Friend: ')
g.send(x.encode())
data = g.recv(1024)
history.append[data]
print("Friend: ", repr(data))
root.mainloop()
Heres client:
# client.py
import socket
host='192.168.1.17' # server side ip address
port=12345
print('Finding...')
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
while 1:
message=input("Say something to Friend: : ")
s.send(message.encode())
data = s.recv(1024)
print('Friend: ', repr(data))
s.close()
So, Tkinter uses the default skin of the available os as far as I know. So it will look closer to MacOs, IOs when you run your python code on a mac. However, you can put custom graphics on buttons etc. and "fake" a MacOS look. Have a look at this Stackoverflow answer:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.