python: remove element from a list (5)
Abstract: consider remove elements from a list
Showing posts with label learning Python. Show all posts
Showing posts with label learning Python. Show all posts
Monday, June 5, 2017
python: the longest palindromic substring (7)
python: the longest palindromic
substring (7)
Abstract: Given
a string, find the length of the longest palindromic substring.
Friday, June 2, 2017
python: the longest substring without repeating characters (6)
python-string: the longest substring
without repeating characters (6)
Abstract: Given
a string, find the length of the longest substring without repeating
characters.
Wednesday, May 31, 2017
Python: binary search (5) Weighing pool balls with n input
Python: binary search (5) Weighing pool balls with n input
Abstract: There
are n ()N.=3 balls are identical in size and appearance, but 1 is an
odd weight which could be either lighter or heavier.
Python: binary search (4) Weighing pool balls
Python: binary search (4) Weighing pool balls
Abstract: 8 out of 9 balls are identical in size and appearance, but 1 is an odd weight which could be either lighter or heavier.
Abstract: 8 out of 9 balls are identical in size and appearance, but 1 is an odd weight which could be either lighter or heavier.
Thursday, March 31, 2016
Python: data structure (6)
Abstract:
Storage of 2-dimension data into nested dictionary, numpy matrix, and
pandas data frame.
Wednesday, January 20, 2016
Python-pandas (7): Sort A Data Frame
Abstract:
Sort rows or columns of a data frame using the function sort() or
sort_index() of the module pandas.
Sunday, November 8, 2015
Python: Pandas(5) group data frame
Abstract:
Statistics of the data frame using the function groupby().
Python: Pandas (3) Create data frame
Abstract:
Create data frame using different approach. Insert or deletion
column/row of a data frame
Python: Pandas (2) merge data frames
Abstract:
merge two data frames using pd.concat() or pd.merge() of the Pandas
module.
Friday, October 23, 2015
Thursday, September 17, 2015
Friday, September 11, 2015
Python: multi-threading (2) threading module
Abstract: the module known as threading used for multiple threads
Python: Multithreading(1) thread module
Abstract: The module known as thread used for multiple threads running
Thursday, September 3, 2015
Python: Tkinter (10)
Abstract: A GUI of ComboBox window
The GUI:

The script:
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 3 10:48:41 2015
@author: yuan
"""
from Tkinter import *
import Pmw
class myWin:
def __init__(self, par):
#
self.par=par
#create toplevel window
self.root = Tk()
self.root.title('ComboBox 1')
#add label
self.label1 = Label(self.root, text='Choose References', relief='sunken',
padx=40, pady=10)
#context of combobox
species = ("mouse", "human", "rat", "dog", "arabidopsis", "worm")
species=sorted(species)
self.cb_specie=self.ComboBox(self.root, species, 'Species', 2)
#
mol=['RNA','DNA','cDNA']
self.cb_type=self.ComboBox(self.root, mol, 'Type', 0)
#
fa_file=['sss.fa','DNA.fa','cDNA.fa']
self.cb_fa_file=self.ComboBox(self.root, fa_file, 'File', 0)
#buttons
f=self.Dibuttons(self.root,self.save_input)
#layout
layout=[ [self.label1],
[self.cb_specie, self.cb_type],
[self.cb_fa_file],
[f] ]
self.grid_layout(layout)
#
self.root.mainloop()
def ComboBox(self,win, items,label='ComboBox',default=0):
cb = Pmw.ComboBox(win, label_text=label, labelpos='wn',
dropdown=1, scrolledlist_items=items )
cb.selectitem(default)
return cb
def Dibuttons(self, win, FUN_save):
f=Frame(win, borderwidth=2)
#button close
self.b_save=Button(f, text='Save',command=FUN_save )
self.b_save.grid(row=0,column=0,sticky=W+N+S+E)
#button close
self.b_close=Button(f, text='Close',command=win.quit)
self.b_close.grid(row=0,column=1,sticky=W+N+S+E)
return f
def save_input(self):
self.par['specie']=self.cb_specie.get()
self.par['type']=self.cb_type.get()
self.par['fa_file']=self.cb_fa_file.get()
print self.par['specie']
def grid_layout(self, displays,row=0):
max_col=max([len(a) for a in displays])
for row_index, display_row in enumerate(displays):
col_num=len(display_row)
#print row_index,max_col/col_num
for col_index, display_col in enumerate(display_row):
print row_index,col_index,max_col/col_num
display_col.grid(row=row+row_index, column=col_index,
columnspan=max_col/col_num)
if __name__=="__main__":
#comboBox window
par={}
cb=myWin(par)
print 'ok'
The GUI:
The script:
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 3 10:48:41 2015
@author: yuan
"""
from Tkinter import *
import Pmw
class myWin:
def __init__(self, par):
#
self.par=par
#create toplevel window
self.root = Tk()
self.root.title('ComboBox 1')
#add label
self.label1 = Label(self.root, text='Choose References', relief='sunken',
padx=40, pady=10)
#context of combobox
species = ("mouse", "human", "rat", "dog", "arabidopsis", "worm")
species=sorted(species)
self.cb_specie=self.ComboBox(self.root, species, 'Species', 2)
#
mol=['RNA','DNA','cDNA']
self.cb_type=self.ComboBox(self.root, mol, 'Type', 0)
#
fa_file=['sss.fa','DNA.fa','cDNA.fa']
self.cb_fa_file=self.ComboBox(self.root, fa_file, 'File', 0)
#buttons
f=self.Dibuttons(self.root,self.save_input)
#layout
layout=[ [self.label1],
[self.cb_specie, self.cb_type],
[self.cb_fa_file],
[f] ]
self.grid_layout(layout)
#
self.root.mainloop()
def ComboBox(self,win, items,label='ComboBox',default=0):
cb = Pmw.ComboBox(win, label_text=label, labelpos='wn',
dropdown=1, scrolledlist_items=items )
cb.selectitem(default)
return cb
def Dibuttons(self, win, FUN_save):
f=Frame(win, borderwidth=2)
#button close
self.b_save=Button(f, text='Save',command=FUN_save )
self.b_save.grid(row=0,column=0,sticky=W+N+S+E)
#button close
self.b_close=Button(f, text='Close',command=win.quit)
self.b_close.grid(row=0,column=1,sticky=W+N+S+E)
return f
def save_input(self):
self.par['specie']=self.cb_specie.get()
self.par['type']=self.cb_type.get()
self.par['fa_file']=self.cb_fa_file.get()
print self.par['specie']
def grid_layout(self, displays,row=0):
max_col=max([len(a) for a in displays])
for row_index, display_row in enumerate(displays):
col_num=len(display_row)
#print row_index,max_col/col_num
for col_index, display_col in enumerate(display_row):
print row_index,col_index,max_col/col_num
display_col.grid(row=row+row_index, column=col_index,
columnspan=max_col/col_num)
if __name__=="__main__":
#comboBox window
par={}
cb=myWin(par)
print 'ok'
Subscribe to:
Posts (Atom)