title: Tkinter -- how to horizontally center canvas text?
body: <p>I'm working on a function in a UI class that is a config window, it displays the logo of the program and has an updating text at the bottom telling you what it's loading, etc.  This is what I have so far:</p>
  
  <pre><code>    self.window = "config"
      self.windowWidth = 340
      self.windowHeight = 270
      infoText = "Configuring Kh..."
      self.root = tk.Tk()
      self.root.geometry("%dx%d+400+400" % (self.windowWidth, self.windowHeight))
      self.root.title("Kh Control v1.1 starting...")
      logo = tk.PhotoImage(file="KhLogo.gif")
      mainPanel = tk.Canvas(self.root, width=self.windowWidth, height=self.windowHeight)
      mainPanel.image = logo
      mainPanel.pack()
      mainPanel.create_image(0, 0, image=logo, anchor="nw")
      mainPanel.create_text(0,200, text=infoText, anchor="nw", fill="yellow")
      return
  </code></pre>
  
  <p>I'd like the text in infoText to be centered horizontally and offset vertically about 200px down.  The vertical offset works fine, but I can't figure out how to center the text horizontally.</p>
  
  <p>I started by trying the age old ((width / 2) - (str length / 2)) but then realized that each letter isn't 1px.  And anchor = "center" seems to only put half the text off the left side of the screen.</p>
  
  <p>I'm very new to Python (only a few days now) so if I'm missing something obvious, that's why.</p>
  
  <p>EDIT: and in case it wasn't obvious, this text will change so I can't just make an absolute decision on the offsets, it has to change with the text</p>