how to execute python code with tkinter user input
<p>when user input cluster in this tkinter code (tkintt.py) and click submit button, i want the program execute k-medoids code (example.py) based on how many cluster that user input but it gets some errors.
could you help me?</p>

<p>tkintt.py</p>

<pre><code>import Tkinter
from _tkinter import *
root = Tkinter.Tk()

label1 = Tkinter.Label(text = " enter cluster : ")
label1.pack()
clvar = Tkinter.IntVar()
cluster = Tkinter.Entry(bd = 5)
clvar = cluster.get()
cluster.pack()

def open1():
  print ("K-MEDOIDS CLUSTERING")
  execfile('example.py')

button_1 = Tkinter.Button(text = "SUBMIT", command = open1)
button_1.pack()
root.mainloop()
</code></pre>

<p>example.py</p>

<pre><code>from k_medoids import KMedoids
import numpy as np
import matplotlib.pyplot as plt


def example_distance_func(data1, data2):
   '''example distance function'''
   return np.sqrt(np.sum((data1 - data2)**2))

if __name__ == '__main__':
   X = np.random.normal(0,3,(500,2))
   model = KMedoids(n_clusters= cluster, dist_func=example_distance_func)
   model.fit(X, plotit=True, verbose=True)
   plt.show()
</code></pre>

<p>error:</p>

<pre><code>    Traceback (most recent call last):
    File "C:\Users\user\Anaconda2\lib\lib-tk\Tkinter.py", line 1537, in __call__
      return self.func(*args)
    File "C:/Users/user/Anaconda2/K_Medoids-master/tkintt.py", line 15, in open1
      execfile('example.py')
    File "example.py", line 13, in &lt;module&gt;
      model.fit(X, plotit=True, verbose=True)
    File "C:\Users\user\Anaconda2\K_Medoids-master\k_medoids.py", line 114, in       fit
    X,self.n_clusters, self.dist_func, max_iter=self.max_iter, tol=self.tol,verbose=verbose)
    File "C:\Users\user\Anaconda2\K_Medoids-master\k_medoids.py", line 54, in _kmedoids_run members, costs, tot_cost, dist_mat = _get_cost(X, init_ids,dist_func)
    File "C:\Users\user\Anaconda2\K_Medoids-master\k_medoids.py", line 37, in _get_cost mask = np.argmin(dist_mat,axis=1)
    File "C:\Users\user\Anaconda2\lib\site-packages\numpy\core\fromnumeric.py", line 1034, in argmin return argmin(axis, out)
    ValueError: attempt to get argmin of an empty sequence
</code></pre>

<p>It appears as if that k-medoid does not handle allethe corner cases correctly.</p>

<p>Most likely, you have an empty cluster.</p>

python python-2.7 tkinter pycharm cluster-analysis