-
المساهمات
7 -
تاريخ الانضمام
-
تاريخ آخر زيارة
نوع المحتوى
ريادة الأعمال
البرمجة
التصميم
DevOps
التسويق والمبيعات
العمل الحر
البرامج والتطبيقات
آخر التحديثات
قصص نجاح
أسئلة وأجوبة
كتب
دورات
أجوبة بواسطة Madara Uchiha
-
-
السلام عليكم
المشكلة هي عندما احاول طابعة شيء باللغة العربية لا يقوم بإظهار الحروف مع بعض
مثال
print("مرحبا")
بإنه يطبعها بهذا الشكل م ر ح ب ا
هل هناك حل لهذه المشكلة أم ان البرنامج لا يدعم العربية
- 1
-
و هذا كود البرنامج
لقد قمت ببعض التعديلات لكنها لم تعمل مثل تاريخ إنهاء الدواء لم اعرف كيف اجعلها تظهر في واجهة البرنامج ليس داخل الفاتورة
import sqlite3
import tkinter as tk
from tkinter import Label, Button, Entry, StringVar, messagebox, Text, ttk
from datetime import datetime, timedelta
root = tk.Tk()
root.title("Medicine Management")
root.resizable(0, 0)
root.configure(bg="#333333")
def start_application():
login_window = tk.Toplevel(root)
login_window.title("Login")
login_window.geometry("500x400")
login_window.resizable(0, 0)
login_window.configure(bg="#333333")
def create_table():
connection = sqlite3.connect("medicine_database.db")
cursor = connection.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS medicines (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
prix_u REAL,
ppa REAL,
date TEXT,
expiry_date TEXT
)
""")
connection.commit()
connection.close()
def add_medicine(name, prix_u, ppa, date, expiry_date):
connection = sqlite3.connect("medicine_database.db")
cursor = connection.cursor()
cursor.execute("SELECT COUNT(*) FROM medicines")
count = cursor.fetchone()[0]
medicine_number = count + 1
name_with_number = f"{medicine_number}. {name}"
cursor.execute("""
INSERT INTO medicines (name, prix_u, ppa, date, expiry_date)
VALUES (?, ?, ?, ?, ?)
""", (name_with_number, prix_u, ppa, date, expiry_date))
connection.commit()
connection.close()
return name_with_number
def calculate_expiry_date(start_date, months):
start_date = datetime.strptime(start_date, "%d/%m/%Y")
expiry_date = start_date + timedelta(days=30 * months)
return expiry_date.strftime("%Y-%m-%d")
def print_invoice(medicine):
total_price = medicine[2] + medicine[3] # Prix U + PPA
invoice_text.delete(1.0, 'end') # Clear previous content
invoice_text.insert('end', f"Number: {medicine[0]}\n")
invoice_text.insert('end', f"Name: {medicine[1]}\n")
invoice_text.insert('end', f"Prix U: {medicine[2]}\n")
invoice_text.insert('end', f"PPA: {medicine[3]}\n")
invoice_text.insert('end', f"Total Price: {total_price}\n")
messagebox.showinfo("Invoice", "Invoice details are displayed in the table below.")
def save_medicine():
name = name_entry.get()
prix_u = float(prix_u_entry.get())
ppa = float(ppa_entry.get())
date = date_entry.get()
start_date = start_date_entry.get()
months = int(months_entry.get())
expiry_date = calculate_expiry_date(start_date, months)
added_medicine_name = add_medicine(name, prix_u, ppa, date, expiry_date)
connection = sqlite3.connect("medicine_database.db")
cursor = connection.cursor()
cursor.execute("SELECT * FROM medicines ORDER BY id DESC LIMIT 1")
last_medicine = cursor.fetchone()
connection.close()
if last_medicine:
# Print invoice
print_invoice(last_medicine)
total_price = last_medicine[2] + last_medicine[3] # Prix U + PPA
# Update Treeview
invoice_tree.insert("", "end", values=(
last_medicine[0], last_medicine[1], last_medicine[2],
last_medicine[3], total_price, last_medicine[4]
))
else:
messagebox.showerror("Error", "No medicine found.")
name_var = StringVar()
prix_u_var = StringVar()
ppa_var = StringVar()
date_var = StringVar()
start_date_var = StringVar()
months_var = StringVar()
Label(root, text="Medicine Name:", bg="#333333", fg="#2af708").grid(row=0, column=0, padx=10, pady=10)
name_entry = Entry(root, textvariable=name_var)
name_entry.grid(row=0, column=1, padx=10, pady=10)
Label(root, text="Prix U:", bg="#333333", fg="#2af708").grid(row=1, column=0, padx=10, pady=10)
prix_u_entry = Entry(root, textvariable=prix_u_var)
prix_u_entry.grid(row=1, column=1, padx=10, pady=10)
Label(root, text="PPA:", bg="#333333", fg="#2af708").grid(row=2, column=0, padx=10, pady=10)
ppa_entry = Entry(root, textvariable=ppa_var)
ppa_entry.grid(row=2, column=1, padx=10, pady=10)
Label(root, text="Manufacture Date:", bg="#333333", fg="#2af708").grid(row=3, column=0, padx=10, pady=10)
date_entry = Entry(root, textvariable=date_var)
date_entry.grid(row=3, column=1, padx=10, pady=10)
Label(root, text="Start Date:", bg="#333333", fg="#2af708").grid(row=4, column=0, padx=10, pady=10)
start_date_entry = Entry(root, textvariable=start_date_var)
start_date_entry.grid(row=4, column=1, padx=10, pady=10)
Label(root, text="Months for Expiry:", bg="#333333", fg="#2af708").grid(row=5, column=0, padx=10, pady=10)
months_entry = Entry(root, textvariable=months_var)
months_entry.grid(row=5, column=1, padx=10, pady=10)
Button(root, text="Add Medicine", command=save_medicine).grid(row=6, column=0, columnspan=2, pady=10)
invoice_text = Text(root, height=10, width=50, wrap='word', bg="#FFFFFF")
invoice_text.grid(row=7, column=0, columnspan=2, padx=10, pady=10)
invoice_tree = ttk.Treeview(root, columns=("Number", "Name", "Prix U", "PPA", "Total Price", "Sale Date"),
show="headings")
invoice_tree.heading("Number", text="Number")
invoice_tree.heading("Name", text="Name")
invoice_tree.heading("Prix U", text="Prix U")
invoice_tree.heading("PPA", text="PPA")
invoice_tree.heading("Total Price", text="Total Price")
invoice_tree.heading("Sale Date", text="Sale Date")
invoice_tree.grid(row=8, column=0, columnspan=2, padx=10, pady=10)
create_table()
root.mainloop()
-
هذا كود login.py
import tkinter as tk
import os
from tkinter import *
from tkinter import Label, Entry, Button, messagebox
from main import *
# Create the main application window
root = tk.Tk()
#root.geometry('1050x750')
root.withdraw() # Hide the main application window
# Function to handle login
def login(username_entry, password_entry, root, login_window):
username = username_entry.get()
password = password_entry.get()
# Check username and password
if username == "admin" and password == "123":
login_window.destroy() # Close the login window
root.deiconify()
messagebox.showinfo("Login Successful", "Welcome to the application!")
return True # Show the main application window
else:
messagebox.showerror("Error", "Invalid username or password")
return False
# Create the login window
login_window = tk.Toplevel(root)
login_window.title("Login")
login_window.geometry('500x400')
login_window.resizable(0, 0)
login_window.configure(bg="#333333")
# Create widgets for login window
login_label = tk.Label(login_window, text="😾ⓦⓔⓛⓛⓒⓞⓜⓔ😾", bg="#333333", fg="#7E30E1", font=("Arial", 30))
username_label = tk.Label(login_window, text="Username", bg="#333333", fg="#2af708", font=("Arial", 14))
username_entry = tk.Entry(login_window, font=("Arial", 15))
password_entry = tk.Entry(login_window, show="*", font=("Arial", 15))
password_label = tk.Label(login_window, text="Password", bg="#333333", fg="#2af708", font=("Arial", 14))
login_button = tk.Button(login_window, text="Ⓛⓞⓖⓘⓝ", bg="#232D3F", fg="#2af708", font=("Arial", 18), command=lambda: login(username_entry, password_entry, root, login_window))
# Place widgets on the screen
login_label.grid(row=0, column=0, columnspan=2, sticky="news", pady=40)
username_label.grid(row=1, column=0)
username_entry.grid(row=1, column=1, pady=15)
password_label.grid(row=2, column=0)
password_entry.grid(row=2, column=1, pady=15)
login_button.grid(row=3, column=0, columnspan=2, pady=30)
# Run the application
root.mainloop()
-
مزال المشكل أظن المشكل في صفحة login.py
-
بتاريخ 2 ساعة قال Mahmoud Hassan19:
وعليكم السلام
اولا لابد من import login في main.py
from login import login
قم بتحديث login في login.py لإرجاع قيمة boolean تشير إلى ما إذا كان تسجيل الدخول ناجحًا أم لا. قم أيضًا بتمرير root إلى وظيفة تسجيل الدخول لتتمكن من إخفائها عند تسجيل الدخول الناجح.
def login(username_entry, password_entry, root): username = username_entry.get() password = password_entry.get() if username == "admin" and password == "123": login_window.destroy() root.deiconify() return True else: messagebox.showerror("Error", "Invalid username or password") return False
استخدم login في البرنامج main . يمكنك إنشاء مثل start_application التي تستدعي login وتقوم بتهيئة main في حالة نجاح تسجيل الدخول.
def start_application(): login_window = tk.Toplevel(root) login_window.title("Login") login_window.geometry("500x400") login_window.resizable(0, 0) login_window.configure(bg="#333333")
في نهاية البرنامج main.py، قم باستدعاء وظيفة start_application لبدء عملية تسجيل الدخول وبدء main.السلام عليكم
شكرا لك أخي محمود على الرد
لقد قمت بتعديل كود login.py و قمت بإضافة التغيير main.py
الان اصبح يعمل الكود حيث استطيع الدخول بكلمة السر بنجاح
لكن يقوم بفتح نافذة فارغة عندما اقوم بغلقها تفتح واجهة البرنامج المطلوب و عند غلقها ترجع واجهة login
ما هو المشكل الان
-
visual studio مشكل في اللغة العربية
في بايثون
نشر
يبدو أن الامر لم يتجح يظهر لي خطأ على ما يبدو
انا استخدم لينكس كنظام اساسي
python3 -m pip install arabic-reshaper
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: arabic-reshaper in ./.local/lib/python3.10/site-packages (3.0.0)