diginoron commited on
Commit
c34af81
·
verified ·
1 Parent(s): 74b0cba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -58,9 +58,7 @@ def get_imports(hs_code: str, year: str, month: str):
58
  return product_name, df, "ستون‌های مورد نیاز در داده‌ها یافت نشد."
59
 
60
  df_sorted = df.sort_values(value_col, ascending=False).head(10)
61
- out = df_sorted[[code_col, title_col, value_col]]
62
- out.columns = ['کد کشور', 'نام کشور', 'ارزش CIF']
63
- return product_name, out, ""
64
  except Exception as e:
65
  return "–", pd.DataFrame(), f"خطا: {str(e)}"
66
 
@@ -128,6 +126,18 @@ button {
128
  border-radius: 5px;
129
  padding: 10px;
130
  }
 
 
 
 
 
 
 
 
 
 
 
 
131
  """
132
 
133
  # --- رابط کاربری سفارشی با Gradio Blocks ---
@@ -155,8 +165,7 @@ def create_custom_interface():
155
  out_name = gr.Markdown(label="**نام محصول**")
156
  out_table = gr.Dataframe(
157
  datatype="pandas",
158
- interactive=True,
159
- headers=["کد کشور", "نام کشور", "ارزش CIF"]
160
  )
161
  out_message = gr.Markdown(label="پیام", visible=True)
162
 
@@ -181,4 +190,4 @@ def create_custom_interface():
181
  # --- راه‌اندازی رابط کاربری ---
182
  if __name__ == "__main__":
183
  demo = create_custom_interface()
184
- demo.launch(show_api=False) # حذف پارامتر theme
 
58
  return product_name, df, "ستون‌های مورد نیاز در داده‌ها یافت نشد."
59
 
60
  df_sorted = df.sort_values(value_col, ascending=False).head(10)
61
+ return product_name, df_sorted, "" # بازگشت تمام ستون‌ها
 
 
62
  except Exception as e:
63
  return "–", pd.DataFrame(), f"خطا: {str(e)}"
64
 
 
126
  border-radius: 5px;
127
  padding: 10px;
128
  }
129
+ .gr-Dataframe table {
130
+ width: 100% !important;
131
+ table-layout: auto !important;
132
+ }
133
+ .gr-Dataframe th, .gr-Dataframe td {
134
+ min-width: 100px !important; /* حداقل عرض برای ستون‌ها */
135
+ max-width: 250px !important; /* حداکثر عرض برای جلوگیری از شلوغی */
136
+ white-space: normal !important;
137
+ word-wrap: break-word !important;
138
+ text-align: center !important;
139
+ padding: 5px !important; /* فاصله داخلی برای خوانایی بهتر */
140
+ }
141
  """
142
 
143
  # --- رابط کاربری سفارشی با Gradio Blocks ---
 
165
  out_name = gr.Markdown(label="**نام محصول**")
166
  out_table = gr.Dataframe(
167
  datatype="pandas",
168
+ interactive=True
 
169
  )
170
  out_message = gr.Markdown(label="پیام", visible=True)
171
 
 
190
  # --- راه‌اندازی رابط کاربری ---
191
  if __name__ == "__main__":
192
  demo = create_custom_interface()
193
+ demo.launch(show_api=False)