Python Forum
Python if statement docx wount work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python if statement docx wount work
#3
Here is the full code:

import tkinter as tk

from docx import Document

HEIGHT = 500
WIDTH = 600

root = tk.Tk()
root.title("Generator")
canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH)
canvas.pack()

background_image = tk.PhotoImage(file='bg123.png')
background_label = tk.Label(root, image=background_image)
background_label.place(x=-6, y=-6)

#dropdown part
# Create a Tkinter variable
tkvar = tk.StringVar(root)
choices = { 'broker','consultant','recruit'}
tkvar.set('broker') # set the default option
popupMenu = tk.OptionMenu(root, tkvar, *choices)
popupMenu.place(x=260,y=95)

def helloCallBack():
 
   if tkvar == 'Broker':
      document = Document()
      document.add_heading("Broker")
      document.save('0034.docx')

button = tk.Button(text="Generate", font=40, command=helloCallBack)
button.place(x=230, y=380)

root.mainloop()
Reply


Messages In This Thread
Python if statement docx wount work - by Selfiatus1 - Jun-07-2019, 03:54 PM
RE: Python if statement docx wount work - by Selfiatus1 - Jun-07-2019, 05:35 PM
RE: Python if statement docx wount work - by woooee - Jun-07-2019, 05:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Code Help - pip install PyMuPDF python-docx pillow Splishsplash92 3 196 Today, 06:49 AM
Last Post: Pedroski55
  I can't for the life of me get this basic If statement code to work CandleType1a 8 404 May-21-2024, 03:58 PM
Last Post: CandleType1a
  no module named 'docx' when importing docx MaartenRo 1 1,195 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Replace a text/word in docx file using Python Devan 4 4,124 Oct-17-2023, 06:03 PM
Last Post: Devan
  python-docx: preserve formatting when printing lines Tmagpy 4 2,287 Jul-09-2022, 01:15 AM
Last Post: Tmagpy
  python-docx- change lowercase to bold, italic Tmagpy 0 1,507 Jul-01-2022, 07:25 AM
Last Post: Tmagpy
  python-docx regex : Browse the found words in turn from top to bottom Tmagpy 0 1,601 Jun-27-2022, 08:45 AM
Last Post: Tmagpy
  python-docx regex: replace any word in docx text Tmagpy 4 2,365 Jun-18-2022, 09:12 AM
Last Post: Tmagpy
  getting an import statement to work in my program barryjo 1 1,720 Dec-06-2021, 04:28 PM
Last Post: snippsat
  Сombine (Merge) word documents using python-docx Lancellot 1 11,805 May-12-2021, 11:07 AM
Last Post: toothedsword

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020