Open Erp Reporting Through Interface - reporting

i have created my module that is asset allocation through interface of which now i want to create report in OPEN ERP v 7 so how i can create reporting through interface
any help please?

You use xlwt,xlrd for Excel formatted reporting, but downside is you have to export it external Excel editor.
xlwt for main Excel sheet creating and xlrd for Excel formula.
import xlrd
import xlwt
ezxf = xlwt.easyxf
styles = self.get_easyxf_styles()
book = xlwt.Workbook(encoding='utf8')
sheet = book.add_sheet(u'Properties')
sheet.portrait = False
sheet.write(0, 9, u'Item #', ezxf('font:bold on;align:wrap off,vert centre,horiz right;font: height 180'))
sheet.write(0, 0, u'Organization name: %s' % (company.name,), ezxf('font:bold on;align:wrap off,vert centre,horiz left;font: height 180'))
sheet.write(rowx, 0, u'Numbering', styles['heading_xf'])
Here is usage of xlrd for Excel formula:
sheet.write(rowx, i, xlwt.Formula('SUM(%s:%s)' %(xlrd.cellname(rowx, 2),
xlrd.cellname(rowx, 8))), styles['number_boldtotal_xf'])
Here is partial snipper of formatting function, you can create your own:
def get_easyxf_styles(self):
styledict = {
'title_xf': easyxf('font: bold on, height 250; align: wrap off, vert centre, horiz left;'),
'small_title_xf': easyxf('font: bold on, height 190; align: wrap off, vert centre, horiz left;'),
}
return styledict

Related

pygame does not access sprite functions after putting the dot "."

I am following a tutorial for a game of ships, and when creating the Player class in the init function I have a strange problem when wanting to access the functions of the Sprite module: when I write the name of the variable and put the point to access its functions remain in white, instead of being colored yellow indicating that it is a reserved word (I am using visual studio)
(Sorry if I do not express myself correctly I am using google translator.)
so the strange is this:
code screenshot
what is indicated in the red boxes should be in yellow (like what I underlined in yellow), since theoretically it would be accessing the functions of a Sprite object therefore it should be highlighted in yellow ...
the problem is that it appears white, as if it did not recognize the variable as a Sprite object
Here is where i create the image directory.
import pygame, random, os, sys
from os import path
img_dir = path.join(path.dirname(__file__), 'img')
And here is the Meteor class:
class Meteor(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
self.image_orig = random.choice(meteor_images)
self.image_orig.set_colorkey("black")
self.image_orig.set_clip()
self.image = self.image_orig.copy()
self.rect = self.image.get_rect()
self.radius = int(self.rect.width*0.85/2) # *0.85 <- se leeria como (el 85% del width) / 2
pygame.draw.circle(self.image, "red", self.rect.center, self.radius)
self.rect.x = random.randrange(0, width)
self.rect.bottom = random.randrange(-100, -50)
self.speedx = random.randrange(-4, 4)
self.speedy = random.randrange(2, 8)
self.rot = 0
self.rot_speed = random.randrange(-8, 8)
self.last_update = pygame.time.get_ticks()
and then here is where create the meteors list:
meteor_images = []
meteor_list = ['meteorBrown_big1.png',
'meteorBrown_big2.png',
'meteorBrown_big3.png',
'meteorBrown_big4.png']
for img in meteor_list:
meteor_images.append(pygame.image.load(path.join(img_dir, img)).convert())
I am not very expert on the subject, what could be the problem??

Adjust a Bokeh DataTable to the window

I would like to automatically adjust the width of a bokeh DataTable to the size of a screen. But I do not find the right way to do it. This line of code is supposed to work :
data_table = DataTable(source=source, columns=columns, height = 300, sizing_mode = 'scale_width', fit_columns=True)
But it does not. My Datatable keeps the same width.
Does anyone know how to solve this problem ?
Thank you.
I'm afraid it's not possible with the current implementation of DataTable - if you don't specify an explicit width in pixels, the width will be set to 600px.
You're welcome to create a feature request on Bokeh's GitHub.
As of 2.2.3 and likely earlier you can use sizing_mode:
import pandas as pd, numpy as np, random, string
from bokeh.models import ColumnDataSource, DataTable, TableColumn
from bokeh.plotting import show
df = pd.DataFrame(np.random.randint(0,100,size=(100, 12)), columns=[(random.randint(1,30) * random.choice(string.ascii_uppercase)) for col in range(12)])
data_table = DataTable(columns = [TableColumn(field=c, title=c) for c in df.columns], sizing_mode='stretch_width', source = ColumnDataSource(df))
show(data_table)

CheckBox is not printed by Adobe Reader DC - iText 7.1.0 for Java

I've got some really big problems with AcroForm CheckBox.
1. CheckBox (in checked state) is not printed by Adobe Reader DC. Even after setting the corresponding FieldFlag. Maybe this is because I have'nt got the font ZapfDingsbats on my Computer?
2. How do I change this font (I want to use Wingdings) for all the symbols (On/Off state) used by the different appearances of the checkbox?
3. Last but not least: How to draw a border around the unchecked CheckBox?
Thanks a lot for every tip and help!
package jumpstart;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import com.itextpdf.forms.PdfAcroForm;
import com.itextpdf.forms.fields.PdfButtonFormField;
import com.itextpdf.forms.fields.PdfFormField;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfPage;
import com.itextpdf.kernel.pdf.PdfWriter;
public class Problem6 {
public static void main(String[] args) throws IOException {
PdfWriter writer = new PdfWriter("problem6.pdf");
PdfDocument pdf = new PdfDocument(writer);
PdfPage page = pdf.addNewPage();
PdfAcroForm form = PdfAcroForm.getAcroForm(pdf, true);
PdfButtonFormField checkBox = PdfFormField.createCheckBox(pdf, new Rectangle(75, 750, 20, 20), "cbName1", "On",
PdfFormField.TYPE_CROSS);
// checkBox.setFieldFlag(PdfAnnotation.PRINT);
form.addField(checkBox, page);
pdf.close();
Desktop.getDesktop().open(new File("problem6.pdf"));
}
}
Part 1. To make the PdfFormField printable you should use the following method:
checkBox.setVisibility(PdfFormField.VISIBLE);
Part 2. In your particular case the appearance of the checkbox is drawn using canvas instructions, not any fonts. This is how it's done:
q
Q
0 20 m
20 0 l
20 20 m
0 0 l
S
Part 3. As you can see, no fonts are used, the cross is drawn with lines.
Thus, it's not possible easily to use different font. You can create your own appearance stream and set it via PdfFormField#setAppearance. But you have to be very careful and know what you are doing.
You can set field border with these lines:
checkBox.setBorderWidth(1);
checkBox.setBorderColor(ColorConstants.BLACK);
But this would set borders for all the appearances, including On and Off. If you want the border to be drawn only for Off appearance, you should create your custom appearance and use PdfFormField#setAppearance.
P.S. Please ask questions separately. The three questions you asked are different ones.

Link a tkinter button to seperate script

I have a tkinter interface with a few entry widgets as inputs. Upon clicking a button I would like those inputs to be sent to a separate script to be processed and a value printed and potentially returned back to the button (I am looking at this for a dual accuracy assessment statistic)
This is a lower scale example of what I have so far and am looking to accomplish
Example Secondary Script: GUI_ConnectorScript
def calculate():
global result
result = int(entry.get())
result += 1
print result
Primary Script: GUI_ConnectorScript
from Tkinter import *
import GUI_ConnectorScript
background = "#A8A8A8"
master = Tk()
screen_width = master.winfo_screenwidth()
screen_height = master.winfo_screenheight()
width = int(screen_width*0.7)
height = int(screen_height*0.7)
size = "%sx%s"%(width,height)
master.geometry(size)
master.title("GIS Display")
text = Text(master, width = 80, height = 40, background = background)
text.pack(expand = TRUE, fill = BOTH)
entry = Entry(master, width=5).place(x=100,y=100)
button = Button(master, text="Calculate", command=GUI_ConnectorScript).place(x=500,y=500)
mainloop()
I have been trying to figure this out for awhile and have look around a lot for an answer. I have found examples similar but I am having an issue getting it to work for my application.
I agree with Parviz, whenever GUI programs get too complicated you should use Object-Oriented Programming.
I can further advice that you use kivy (if possible) instead of tkinter, its much better for bigger projects

PyGTK Transparent Window

I want the window transparent, but the label to be 100% in opacity. How can I achieve this? BTW: I noticed when I upgraded to Ubuntu 12.04's unity interface that window.set_opacity wasn't working like it did on GNOME, but even if it did all the content inside the window would become transparent as well.
This is the code I started out with...
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import pango
import time
class Clock:
def __init__(self):
me = gtk.Window(gtk.WINDOW_TOPLEVEL)
me.connect("destroy", lambda w: gtk.main_quit())
me.set_decorated(False)
me.set_has_frame(False)
me.set_resizable(False)
me.set_property('skip-taskbar-hint', True)
self.label = gtk.Label()
self.label.modify_font(pango.FontDescription("FreeSerif Bold 50"))
attr = pango.AttrList()
fg_color = pango.AttrForeground(65535, 0, 0, 0, 65535)
attr.insert(fg_color)
self.label.set_attributes(attr)
me.add(self.label)
me.show_all()
def update(self):
self.label.set_text(time.strftime('%H:%M:%S'))
return True
clock = Clock()
gtk.timeout_add(200, clock.update)
gtk.main()
I found this topic on askubuntu and It's exactly what I was looking for however now I'm having problems having the digital clock show. Any help would be greatly appreciated.
Here's my code.
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import pango
import time
import cairo
class Clock (gtk.Window):
def __init__(self):
super(Clock, self).__init__()
self.connect("destroy", lambda w: gtk.main_quit())
self.set_decorated(False)
self.set_has_frame(False)
self.set_resizable(False)
self.set_property('skip-taskbar-hint', True)
self.label = gtk.Label()
self.label.modify_font(pango.FontDescription("FreeSerif Bold 50"))
attr = pango.AttrList()
fg_color = pango.AttrForeground(65535, 0, 0, 0, 65535)
attr.insert(fg_color)
self.label.set_attributes(attr)
self.screen = self.get_screen()
self.visual = self.screen.get_rgba_visual()
self.set_visual(self.visual)
self.set_app_paintable(True)
self.connect("draw", self.area_draw)
self.add(self.label)
self.show_all()
def update(self):
self.label.set_text(time.strftime('%H:%M:%S'))
return True
def area_draw(self, widget, cr):
cr.set_source_rgba(.2, .2, .2, 0.5)
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.paint()
cr.set_operator(cairo.OPERATOR_OVER)
clock = Clock()
gtk.timeout_add(200, clock.update)
gtk.main()
Well, you have to hack a lot to make a label like this.
The best is to reinvent the wheel: make a round one.
Draw your own label.
Get window context ( mywin.window.cairo_create())) and keep track of x, y.
def draw(*args):
ctx = win.window.cairo_create()
ctx.set_source_rgba(0, 0, 0, 0)
ctx.set_operator(0) # OPERATOR_CLEAR
ctx.paint()
ctx.set_source_rgba(0, .6, 1, .3)
ctx.arc(w/2, h/2, w/2, 0, 2*3.1415)
ctx.fill()
ctx.set_source_rgba(1, .8, 0, 1)
ctx.show_text('29-May-1234') #you have some work for font, style and so on
google gives you an hack that use ctypes for loading ttf font from file; it works very well on Linux( I have no idea on win).
NOTE: Above asume that you have an composit manager, or ... rgba for widget is None.
Also put an
colormap = self.win.get_screen().get_rgba_colormap()
if colormap == None: colormap = self.win.get_screen().get_rgb_colormap()
gtk.widget_set_default_colormap(colormap)
to set rgba if posible, and also it worth a check:
if self.win.is_composited():print ('OK!')
else:self.bg = self.capt_screen()
...........
def capt_screen(self):
x, y = self.win.get_position()
win = gtk.gdk.get_default_root_window()
w, h = win.get_size()
pb = gtk.gdk.Pixbuf(0 , False, 8, w, h)
self.win.hide()
pb = pb.get_from_drawable(win, win.get_colormap(), 0, 0, 0, 0, w, h)
self.win.show_all()
if (pb != None):
im = Image.fromstring('RGB', (w, h), pb.get_pixels())
im = im.crop((x, y, x + self._w, y + self._h))
im = im.convert('RGBA')
return im #or pb
The above is „xp” transparent efect: copy the bg and bledit with your win. Only if it is not a composit manager runing. Is ok for widget - stay on desk, but flickr for something else: at every refresh window has to hide itself, capture the gb, drawing and reveal.
PS: I have an working clock example, but I use png. If you like, i could send you an tar.gz on mail

Resources