from xlrd import open_workbook
wb = open_workbook('test.xls', formatting_info=True)
sheet = wb.sheet_by_index(0)
cell = sheet.cell(0, 0)
xf_index = cell.xf_index
xf = wb.xf_list[xf_index]
format_key = xf.format_key
format = wb.format_map[format_key]
format_str = format.format_str
print(format_str)
import javax.swing.UIManager.*;
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and feel.
}
from bottle import response
@route('/<width:int>/<height:int>')
def index(width, height):
...
image = Cubic(width=width, height=height, filename=randomname, cube_size=90)
image.paint()
img_bytes = open(randomname, 'rb').read()
os.remove(randomname)
response.set_header('Content-type', 'image/png')
return img_bytes
localStorage.setItem("notepadText", 'Lorem ipsum...');
document.getElementById("notepad").innerHTML = localStorage.notepadText;
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Receipt, Ingredient
ReceiptFormSet = inlineformset_factory(Receipt, Ingredient, fields=('name', 'count', 'value'))
from forms import ReceiptFormSet
def receipt_new(request):
if request.method == "POST":
formset = ReceiptFormSet(request.POST)
if formset.is_valid():
formset.save()
return redirect('/receipts')
else:
formset = ReceiptFormSet()
return render(request, 'admin_site/receipt_edit.html', {'formset': formset})
<form method="post" action="">
<table>
{{ formset }}
</table>
</form>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>526</width>
<height>373</height>
</rect>
</property>
<property name="windowTitle">
<string>Threading Demo</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_log_list">
<property name="text">
<string>Отчёт:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="list_log"/>
</item>
<item>
<widget class="QProgressBar" name="progress_bar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="buttons_layout">
<item>
<widget class="QPushButton" name="btn_stop">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Стоп</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_start">
<property name="text">
<string>Старт</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
from PyQt4 import QtGui, uic
from PyQt4.QtCore import QThread, SIGNAL
import sys
import time
class xmlParserThread(QThread):
def __init__(self, xml):
QThread.__init__(self)
self.xml = xml
def __del__(self):
self.wait()
def run(self):
for x in range(25):
self.emit(SIGNAL('notify_progress(QString)'), str(x))
self.sleep(1)
class ThreadingDemo(QtGui.QMainWindow):
def __init__(self):
super(self.__class__, self).__init__()
uic.loadUi('design.ui', self)
self.btn_start.clicked.connect(self.start_getting_top_posts)
def start_getting_top_posts(self):
self.progress_bar.setMaximum(25)
self.progress_bar.setValue(0)
self.xml_parser_thread = xmlParserThread('some.xml')
self.connect(self.xml_parser_thread, SIGNAL("notify_progress(QString)"), self.notify_progress)
self.connect(self.xml_parser_thread, SIGNAL("finished()"), self.done)
self.xml_parser_thread.start()
self.btn_stop.setEnabled(True)
self.btn_stop.clicked.connect(self.xml_parser_thread.terminate)
self.btn_start.setEnabled(False)
def notify_progress(self, counter):
self.list_log.addItem(counter)
self.progress_bar.setValue(self.progress_bar.value() + 1)
def done(self):
self.btn_stop.setEnabled(False)
self.btn_start.setEnabled(True)
self.progress_bar.setValue(0)
QtGui.QMessageBox.information(self, "Done!", "Done parsing XML!")
def main():
app = QtGui.QApplication(sys.argv)
form = ThreadingDemo()
form.show()
app.exec_()
if __name__ == '__main__':
main()
@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
list_display = ('__str__', 'customer_link')
def customer_link(self, obj):
if obj.customer:
return u'<a href="{0}">{1}</a>'.format(reverse('admin:auth_user_change', args=(obj.customer.pk,)), obj.customer)
else:
return obj.customer_fio
customer_link.allow_tags = True
customer_link.admin_order_field = 'customer'
customer_link.short_description = Order._meta.get_field('customer').verbose_name.title()
@python_2_unicode_compatible
class Order(models.Model):
customer = models.ForeignKey(User, verbose_name=u'Заказчик', null=True, blank=True, related_name='orders')
customer_fio = models.CharField(u'ФИО заказчика', max_length=150)