This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
window = tk.Tk() | |
window.title("Guessing Game") | |
lblInst = tk.Label(window, text = "Guess a number from 0 to 9") | |
lblLine0 = tk.Label(window, text = "*********************************************************************") | |
# append elements to grid | |
lblInst.grid(row=0, column=0, columnspan=5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
window = tk.Tk() | |
window.title("Guessing Game") | |
lblInst = tk.Label(window, text = "Guess a number from 0 to 9") | |
lblLine0 = tk.Label(window, text = "*********************************************************************") | |
lblNoGuess = tk.Label(window, text = "No of Guesses: 0") | |
lblMaxGuess = tk.Label(window, text = "Max Guess: 3") | |
lblLine1 = tk.Label(window, text = "*********************************************************************") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
from random import randrange | |
window = tk.Tk() | |
window.title("Guessing Game") | |
lblInst = tk.Label(window, text = "Guess a number from 0 to 9") | |
lblLine0 = tk.Label(window, text = "*********************************************************************") | |
lblNoGuess = tk.Label(window, text = "No of Guesses: 0") | |
lblMaxGuess = tk.Label(window, text = "Max Guess: 3") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
window = tk.Tk() | |
window.title("Sever") | |
# Top frame consisting of two buttons widgets (i.e. btnStart, btnStop) | |
topFrame = tk.Frame(window) | |
btnStart = tk.Button(topFrame, text="Connect", command=lambda : start_server()) | |
btnStart.pack(side=tk.LEFT) | |
btnStop = tk.Button(topFrame, text="Stop", command=lambda : stop_server(), state=tk.DISABLED) | |
btnStop.pack(side=tk.LEFT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
import socket | |
import threading | |
window = tk.Tk() | |
window.title("Sever") | |
# Top frame consisting of two buttons widgets (i.e. btnStart, btnStop) | |
topFrame = tk.Frame(window) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import threading | |
##### GUI component omitted ####### | |
### See https://gist.github.com/effiongcharles/9d0d4fa3163b3350f1399902058fb9ae.js for preceeing source codes | |
server = None | |
HOST_ADDR = "0.0.0.0" | |
HOST_PORT = 8080 | |
client_name = " " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### several lines of codes ommitted | |
### See https://gist.github.com/effiongcharles/290854dba0f1bea7a609138cd9efcd65.js for preceeing codes | |
def accept_clients(the_server, y): | |
while True: | |
client, addr = the_server.accept() | |
clients.append(client) | |
# use a thread so as not to clog the gui thread | |
threading._start_new_thread(send_receive_client_message, (client, addr)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### several lines of codes ommitted | |
### See https://gist.github.com/effiongcharles/4976708e0791cfc959953743e4650b5e.js for preceeing codes | |
# Function to receive message from current client AND | |
# Send that message to other clients | |
def send_receive_client_message(client_connection, client_ip_addr): | |
global server, client_name, clients, clients_addr | |
client_msg = " " | |
# send welcome message to client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
from tkinter import messagebox | |
window = tk.Tk() | |
window.title("Client") | |
username = " " | |
topFrame = tk.Frame(window) | |
lblName = tk.Label(topFrame, text = "Name:").pack(side=tk.LEFT) | |
entName = tk.Entry(topFrame) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: several lines of codes omitted. | |
# For previous codes see: https://gist.github.com/effiongcharles/de4b7622591b5f414ab814733fe6ff02.js | |
client = None | |
HOST_ADDR = "0.0.0.0" | |
HOST_PORT = 8080 | |
def connect_to_server(name): | |
global client, HOST_PORT, HOST_ADDR | |
try: |
OlderNewer